在ubuntu下创建python3环境

  • 在ubuntu下创建python3环境
      • 下载python3.7.0
      • 下载pip3
          • 问题
      • 安装venv
          • 问题
      • 下载ipython&jupyter
          • 问题

在ubuntu下创建python3环境

很好的文档

下载python3.7.0

  1. 官网下载tgz文件
  2. 用tar命令解压到/usr/bin/python (事先创建文件夹)
  3. 进入该位置
  4. ./configure
  5. sudo make
  6. sudo make install 编译

编译过程中问题:

下载pip3

下面参照

sudo apt-get -y upgrade

The -y flag will confirm that we are agreeing for all items to be installed, but depending on your version of Linux, you may need to confirm additional prompts as your system updates and upgrades.

不知道为什么不自带pip

sudo apt-get install -y python3-pip

There are a few more packages and development tools to install to ensure that we have a robust set-up for our programming environment:

sudo apt-get install build-essential libssl-dev libffi-dev python3-dev

Once Python is set up, and pip and other tools are installed, we can set up a virtual environment for our development projects.

问题

pip依附与特定版本的python么?
怎么看依附与哪个版本?

安装venv

sudo apt-get install -y python3-venv
mkdir environments
cd environments

失败

python3 -m venv my_env  
#Error: Command '['/home/tshogx/python3.7_environments/try_env_1/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
source my_env/bin/activate  
#bash: source: try_env_1/bin/python3: cannot execute binary file

修改为 成功

python3.5 -m venv my_env
source my_env/bin/activate

(my_env) tshogx@tshogx-Ubuntu:~$ 

Note: Within the virtual environment, you can use the command python instead of python3, and pip instead of pip3 if you would prefer. If you use Python 3 on your machine outside of an environment, you will need to use the python3 and pip3 commands exclusively.

尝试理解该环境

  1. 目录结构?为什么lib里有python3.7?
  2. 操作方法

尝试在该环境运行,配合ipython,代替pycharm
pipenv?

问题

此时venv默认python3.5
如何改成3.7?

下载ipython&jupyter

ipython

sudo pip3 install ipython
黄字
# The directory '/home/tshogx/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
# The directory '/home/tshogx/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

下载jupyter

pip3 install jupyter

失败

command -v pip3
# 找到pip3路径
sudo [路径] install jupyter
# 成功
问题
  1. jupyter发生了什么?为什么不能直接用pip3?
  2. 如何使用ipython?

1
1

你可能感兴趣的:(python)