Reputation: 4155
I recently updated from Python 2.7.6 to Python 2.7.9 on my Mac. My issue is that I cannot create a new virtualenv
using Python 2.7.9 with the -p
flag.
When I open the Python shell outside a virtual environment it is using 2.7.9:
localhost:test6 brendan$ python
Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
However, when I create a new virtual environment using either virtualenv
or mkvirtualenv
it continues to use 2.7.6.
I understand that I can use the -p
flag to create a virtual environment using a specific version of Python (e.g. 3.0, 2.6, etc.), but each of these have their own executable e.g.
virtualenv -p /usr/bin/python3.0 test6
or
virtualenv -p /usr/bin/python2.6 test7
I do not seem to have a python2.7.9
executable located in /usr/bin
or anywhere else. I do have a python2.7
executable, but if I specify this:
virtualenv -p /usr/bin/python2.7 test7
the resulting virtual environment still uses the 2.7.6 version of Python. I thought the installation of Python 2.7.9 should have updated the python2.7
executable in /usr/bin/
?
So my question is: where is my Python 2.7.9 executable located, and how do I specify it when creating a new virtual environment?
Upvotes: 0
Views: 249
Reputation: 415
The /usr/bin/python2.7 is simply a symbolic link to the actual python binary which could be located somewhere else. Most likely if you execute /usr/bin/python2.7 --version it will show you "Python 2.7.6".
I have not tried this on mac, but have done it on Linux, is to get a specific version of python and compile it manually in my path /users//mypython, and then modify the symbolic link in /usr/bin/python to point to my version.
Upvotes: 0
Reputation: 7377
Use which
to find which executable is being run from the command line, then use that to create the virtualenv.
Something like
virtualenv -p $(which python) test7
Upvotes: 1