Search code examples
pythonmacospipvirtualenvmacports

Wrong virtualenv path installed with pip and macport


I failed to install virtualenv on Mac OS 10.9 using pip and macport.

After installation with pip install virtuanenv I found the virtualenv was installed into /opt/local/Library/Fraemworks/Python.framework/Versions/2.7/bin.

But it should be in /opt/local/bin. How to fix it?


Solution

  • MacPorts cannot install an executable named virtualenv in /opt/local/bin because MacPorts supports multiple versions of Python and the different virtualenvs for the different Python versions would conflict on these files.

    You can, however, install the py27-virtualenv port using sudo port install py27-virtualenv, which will give you virtualenv-2.7 in /opt/local/bin. Additionally, installing the py27-virtualenv port will pull in the virtualenv_select port, which allows you to use MacPorts' select mechanism to choose your preferred version of virtualenv:

    sudo port select --set virtualenv virtualenv27 should then create a symlink /opt/local/bin/virtualenv -> virtualenv-2.7, which sounds like what you want.