简体   繁体   中英

Mac use different Python version with virtualenv

I just installed Python 2.7.6.

$ python -V
Python 2.7.6

$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

When I try to specify the Python version while creating a new virtualenv with

virtualenv -p /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7.6 test

I get:

The executable /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7.6 (from --python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7.6) does not exist

If I simply use virtualenv test to create a new virtualenv I still get Python 2.7.5. What am I doing wrong?

Use the value returned by which :

virtualenv -p /Library/Frameworks/Python.framework/Versions/2.7/bin/python test

Python installations generally create executables and/or links to them with names like:

python
python2
python2.7

but not

python2.7.6

If you are concerned about confusion with the Apple-supplied system Python 2.7, don't be. Its path is at /usr/bin/python or /usr/bin/python2.7 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM