l Linux 环境安装
1. 安装一些乱七八糟的库...
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel mysql-devel gcc gcc-devel python-devel
2. 下载源码(下载至 usr/tmp)
wget "https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz"
3. 解压
tar -zxvf Python-3.5.0.tgz
4. 创建pyrhon3的文件夹
mkdir /usr/local/python3
5. 编译(出错可能没安装gcc yum install gcc)
Python-3.5.0/configure --prefix=/usr/local/python3
7. 源码编译
make
make install
8. 启动py3 /usr/local/python3/bin/python3 替换为python3,链接到/usr/bin/python3。使用python3默认环境变量会去/usr/bin/下搜索
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
安装pip3 和 virtualenv
1.替换环境变量
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
2.只能装virtualenv
pip install virtualenv
3.替换环境变量
ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv
4.创建虚拟环境test
virutalenv -p /usr/bin/python3 test
5.启动虚拟环境
source bin/activate
6.退出虚拟环境
deactivate
安装virtualenvwrapper:
1. 安装:
pip install virtualenvwrapper
2.编辑添加
环境变量:
vim ~/.bashrc
文末添加:
export WORKON_HOME=~/.virtualenvs
source /usr/bin/virtualenvwrapper.sh
·source ~/.bashrc
:这里会报错/usr/bin/virtualenvwrapper.sh: No such file or directory
该目录下没有virtualenvwrapper.sh
。
搜索这个文件在哪里:
find / -name virtualenvwrapper.sh
发现在这个目录下:/usr/local/python3/bin/virtualenvwrapper.sh 替换!
再:
source ~/.bashrc
OOOOOOKKKKK!!!!!!!