看了你就懂了
https://segmentfault.com/a/1190000004079979html
你在一个机器上 开发不通的项目,须要不通版本的python怎么办node
1.首先安装python3
http://www.th7.cn/Program/Python/201512/743392.shtmlpython
cd /usr/local/ curl -O https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz tar -zxf Python-3.5.0.tgz cd Python-3.5.0/ ./configure make make install
第三方的东西,最好下载到这个目录下react
[root@hk45-node02-47 Python-3.5.0]# cd /usr/local [root@hk45-node02-47 local]# ls aegis bin etc games include lib lib64 libexec nginx nom Python-3.5.0 Python-3.5.0.tgz sbin share src
老的:nginx
[root@hk45-node02-47 local]# /usr/bin/python -V Python 2.7.5 [root@hk45-node02-47 local]# /usr/bin/pip -V pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
新的:json
[root@hk45-node02-47 local]# /usr/local/bin/python3 -V Python 3.5.0 [root@hk45-node02-47 local]# /usr/local/bin/pip3 -V pip 7.1.2 from /usr/local/lib/python3.5/site-packages (python 3.5)
install python3.5 but you did not install pip3.5 , I suggest you to install python3.4 and pip3.4bootstrap
el7 install python3.4 and pip3vim
[root@us44-47 local]# yum install epel-release -y [root@us44-47 local]# yum install python34 -y [root@us44-47 local]# curl https://bootstrap.pypa.io/get-pip.py | python3.4 [root@singapore-47 local]# which python3 /usr/local/bin/python3 [root@singapore-47 local]# which python3.4 /usr/bin/python3.4 [root@singapore-47 local]# which python3.5 /usr/local/bin/python3.5 [root@singapore-47 local]# ll /usr/local/bin/python3 lrwxrwxrwx 1 root root 9 6月 20 13:36 /usr/local/bin/python3 -> python3.5 [root@singapore-47 local]# ln -sf /usr/bin/python3.4 /usr/local/bin/python3 [root@singapore-47 local]# python3 -V Python 3.4.3
2.安装virtualenv,virtualenvwrappersegmentfault
[root@hk45-node02-47 local]# pip3 install virtualenv [root@hk45-node02-47 local]# pip3 install virtualenvwrapper 本身内心要知道本身安装的virtualenvwrapper.sh在哪里 [root@hk45-node02-47 local]# which virtualenvwrapper.sh /usr/local/bin/virtualenvwrapper.sh [root@hk45-node02-47 local]# vim ~/.bashrc 添加: export WORKON_HOME='~/.virtualenvs' source /usr/bin/virtualenvwrapper.sh
之后,你就可使用workon了bash
3.如今你的机器上有了python2.7 和python3,你须要用virtualenv 搞一个 python3的环境
[root@hk45-node02-47 ahao.mah]# virtualenv -p /usr/local/bin/python3 csvt15 Running virtualenv with interpreter /usr/local/bin/python3 Using base prefix '/usr/local' New python executable in /home/ahao.mah/csvt15/bin/python3 Also creating executable in /home/ahao.mah/csvt15/bin/python Installing setuptools, pip, wheel...done. [root@hk45-node02-47 ahao.mah]# ll csvt15 总用量 16 drwxr-xr-x 2 root root 4096 6月 17 22:58 bin drwxr-xr-x 2 root root 4096 6月 17 22:58 include drwxr-xr-x 3 root root 4096 6月 17 22:58 lib -rw-r--r-- 1 root root 60 6月 17 22:58 pip-selfcheck.json
[root@hk45-node02-47 ahao.mah]# mkvirtualenv -p /usr/local/bin/python3 csvt16 Running virtualenv with interpreter /usr/local/bin/python3 Using base prefix '/usr/local' New python executable in /root/.virtualenvs/csvt16/bin/python3 Also creating executable in /root/.virtualenvs/csvt16/bin/python Installing setuptools, pip, wheel...done. virtualenvwrapper.user_scripts creating /root/.virtualenvs/csvt16/bin/predeactivate virtualenvwrapper.user_scripts creating /root/.virtualenvs/csvt16/bin/postdeactivate virtualenvwrapper.user_scripts creating /root/.virtualenvs/csvt16/bin/preactivate virtualenvwrapper.user_scripts creating /root/.virtualenvs/csvt16/bin/postactivate virtualenvwrapper.user_scripts creating /root/.virtualenvs/csvt16/bin/get_env_details (csvt16) [root@hk45-node02-47 ahao.mah]# python -V Python 3.5.0