本文主要讲解python2与python3的共存和使用问题
目的:新建virtual是python3和python2运行环境分离,且好处是,py3env可以复制粘贴
1、安装
mac:
python2.7:自带
python3.5:
brew install python3 (已测试)
linux:
python2.7:自带
python3.5:
http://www.cnblogs.com/freeweb/p/5181764.html (已测试)
yum install python34 ( 另一种方式 )
windows:
直接下载安装即可
2、创建virtualenv
mac:
pip install -U pip pip install virtualenv virtualenv -p python3 py3env source py3env/bin/activate pip install ipython deactivate
linux:
yum -y install epel-release
yum -y install python-pip
pip install -U pip pip install virtualenv virtualenv -p python3 py3env source py3env/bin/activate pip install ipython deactivate
windows:
pip install -U pip pip install virtualenv virtualenv -p 【python3的绝对地址】 py3env start 【绝对地址】/py3env/Scripts/activate.bat pip install ipython
start 【绝对地址】/py3env/Scripts/deactivate.bat
3、通过alias进入python3
mac、linux:
shell如果是bash,则配置~/.bashrc,每次启动shell都会运行
shell如果是zsh,则配置~/.zsh, 每次启动shell都会执行
加入内容:
alias py3="source ~/py3env/bin/activate"
alias deactive="source ~/py3env/bin/deactivate"
windows:
1、新建alias文件夹
2、新建py3.bat,内容:
start 【绝对地址】/py3env/Scripts/activate.bat
3、新建deactive,内容
start 【绝对地址】/py3env/Scripts/deactivate.bat
4、将alias文件夹,加入path,重启则全局生效
4、进入环境
python 进入python2
pip 进入python2的pip
py3 进入python3
pip 进入python3的pip
ipython和pip一样