Skip to content Skip to sidebar Skip to footer

Error Message For Virtualenvwrapper On OS X Lion

I've used homebrew to install python on a new Mac Lion installation, and have been trying to install virtualenv and virtualenvwrapper with pip, but when I start a new terminal sess

Solution 1:

Since you have your own version of python, have you tried overriding VIRTUALENVWRAPPER_PYTHON? (It looks like you want export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python) The virtualenvwrapper docs suggest setting that envvar to the desired python before sourcing virtualenvwrapper.sh. Their example has:

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh

Solution 2:

Add or change path into ~/.bash_profile for virtualenvwrapper.sh to /usr/local/share/python/virtualenvwrapper.sh

it should look like

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export WORKON_HOME=$HOME/.virtualenvs

source /usr/local/share/python/virtualenvwrapper.sh

Solution 3:

I ran into similar problems with Hombrew-installed Python conflicting with the system-installed Python under OS X Lion. I was never able to correct the problem using Homebrew. However, when I switched to using pythonbrew (https://github.com/utahta/pythonbrew) to manage my installed Pythons (instead of Homebrew), I was able to run virtualenvwrapper successfully.


Solution 4:

If your using PythonBrew & VirtualEnvBurrito with ZSH shell, make sure you check out your .zprofile - this contains some commands to execute the VirtualEnvBurrito startup script. As .zprofile is loaded before .zshrc the Python version is the system one. This will also throw up this error.


Solution 5:

I was facing similar issues on macOS Catalina. It ships with zsh & python 2.7

With the following steps I installed python3 and virtual env,

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Install python

brew install python

Check where python is installed

brew show python

Squashed output,

==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

Default python path on macOS is /usr/bin/python which points to Python 2.7. So we need to create an alias from python to python3

alias python=/usr/local/bin/python3

And then follow the steps as mentioned by @munchybunch above,

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

Following the steps above, I was able to create a virtual env,

mkvirtualenv dev

Post a Comment for "Error Message For Virtualenvwrapper On OS X Lion"