ubuntu16.04安装python3.7+pipenv(最新、详细、原创、可用)

ubuntu16.04安装python3.7+pipenv

1. 安装python3.7

ubuntu默认是python3.5

1. 下载、解压、编译,安装
# 下载python3的安装包
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

# 解压源码:
tar -zxvf Python-3.7.0.tgz -C ~
cd Python-3.7.0

# 安装源码编译所需的各种依赖库:(Ubuntu16.04环境下)
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev

# 配置安装位置 配置优化:
./configure --prefix=/usr/local --enable-optimizations

# 编译:
make -j 4

# 安装:
sudo make install

sudo make altinstall

2. 创建python3.7的软连接
cd /usr/bin/

mv python python.backup  # 备份python

ln -s /usr/local/bin/python3.7 /usr/bin/python  # 为p3.7创建软连接名为python

ln -s /usr/local/bin/pip3.7 /usr/bin/pip3.7  # 为pip3.7创建软连接为pip3.7

python -V  # 查看python版本

pip3.7 -V  # 查看pip版本

2.安装pipenv

1.安装

pip3.7 install --user pipenv

2. 修改配置项

使用命令:python -m site --user-basepython3 -m site --user-base,查看电脑用户的基础目录路径,会得到:

类似与 /home/python/.local  或  /home/python/./local/lib/python3.6/site-packages

使用命令:vi ~/.profile,在最后添加:

export PATH=$PATH:/home/python/.local/bin   # 注意:末尾添加/bin

执行:source ~/.profile

若报错:

/usr/bin/python: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks. 

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is

解决:

sudo pip3 install virtualenv virtualenvwrapper

source .bashrc

再次:

source ~/.profile

执行pipenv查看是否成功。

你可能感兴趣的:(ubuntu16.04,python3.7,pipenv,离线安装,python,ubuntu)