Mac下virtual环境配置

mac中需要用到python2的环境,但之前把python2删除了,

需要重新安装:

到官网下载安装包:https://www.python.org/downloads/release/python-2711/

傻瓜式安装好后:

 

~/Github/ganglia-api on master 13:54:43

$ which python

/usr/bin/python

 

~/Github/ganglia-api on master 14:02:23

$ which python2

/usr/local/bin/python2

 

 

安装虚拟环境工具:

~ 14:10:08

$ pip2 install virtualenv

 

无论使用pip2还是pip3安装的virtualenv都是一样的,默认情况下,pip2无法找到virtualenv

 

~ 14:11:05

$ pip3 install virtualenv

Requirement already satisfied: virtualenv in /usr/local/lib/python3.7/site-packages (16.4.3)

 

 

配置python2python3的虚拟环境目录:

~ 14:20:21

$ virtualenv -p /usr/local/bin/python2 .py2_env

Running virtualenv with interpreter /usr/local/bin/python2

New python executable in /Users/along/.py2_env/bin/python

Installing setuptools, pip, wheel...

done.

 

 

~ 14:20:50

$ virtualenv -p /usr/local/bin/python3 .py3_env

Running virtualenv with interpreter /usr/local/bin/python3

Using base prefix '/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7'

New python executable in /Users/along/.py3_env/bin/python3.7

Also creating executable in /Users/along/.py3_env/bin/python

Installing setuptools, pip, wheel...

done.

 

 

 

 

或:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages 16:14:08

$ chmod +x virtualenv.py

 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages 16:14:30

$ ./virtualenv.py -p /usr/local/bin/python2 ~/.py2_env

Running virtualenv with interpreter /usr/local/bin/python2

New python executable in /Users/along/.py2_env/bin/python

Installing setuptools, pip, wheel...

done.

 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages 16:15:04

$ ./virtualenv.py -p /usr/local/bin/python3 ~/.py3_env

Running virtualenv with interpreter /usr/local/bin/python3

Using base prefix '/Library/Frameworks/Python.framework/Versions/3.7'

New python executable in /Users/along/.py3_env/bin/python3

Also creating executable in /Users/along/.py3_env/bin/python

Installing setuptools, pip, wheel...

done.

 

 

 

python2安装module:

~ 14:24:20

$ cd .py2_env/bin 

 

~/.py2_env/bin 14:24:27

$ source activate

(.py2_env)

~/.py2_env/bin 14:24:55

$

 

(.py2_env)

~/.py2_env/bin 14:26:54

$ pip install tornado

 

 

 

 

 

 

 

 

你可能感兴趣的:(BD)