patkil
patkil

Reputation: 2089

"virtualenv is not compatible with this system or executable" using virtual env and anaconda

I'm trying to start up a virtual env using virtualenv, am getting this error:

Already using interpreter /Users/pkilcrease/anaconda/bin/python3
Using base prefix '/Users/pkilcrease/anaconda'
New python executable in /Users/pkilcrease/.virtualenvs/bodega/bin/python3
Also creating executable in /Users/pkilcrease/.virtualenvs/bodega/bin/python
ERROR: The executable /Users/pkilcrease/.virtualenvs/bodega/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/Users/pkilcrease/.virtualenvs' (should be '/Users/pkilcrease/.virtualenvs/bodega')
ERROR: virtualenv is not compatible with this system or executable

The command I am running is mkvirtualenv -a . --no-site-packages --python='which python3' -r requirements.txt bodega

My .bashrc file currently looks like this:

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/Users/pkilcrease/anaconda/bin/virtualenvwrapper.sh
source /Users/pkilcrease/anaconda/bin/virtualenvwrapper_lazy.sh

I have the feeling that there is some issue with anaconda and virtualenv which is causing the problem here, but not sure how to remedy that or if it's just a red herring.

Upvotes: 6

Views: 3210

Answers (2)

user2804865
user2804865

Reputation: 1064

Hopefully this may help people still looking at this question, but an easy fix:

conda install -y virtualenv

Upvotes: -1

michael
michael

Reputation: 9759

If using a conda python executable, use conda create --name {your_venv} python=3 (note there is a virtualenv utility that comes with conda, but still use conda create... to make new virtual env's).

Otherwise, when using a version of python installed by the system package manager, create a virtual env using virtualenv, or preferably using the virtualenvwrapper utility mkvirtualenv. For example on Linux, the "system python" is /usr/bin/python3, /usr/bin/python, /usr/bin/python2, etc. Or, as it's clear you're on MacOS, that would likely be a python installed by brew (homebrew) or port (macports) in /opt or /usr/local. You may have to install virtualenvwrapper in order to get mkvirtualenv (and lsvirtualenv, etc).

In short, if you're using anaconda python, stick with conda utils. Else, if you're keeping your python free & open (as many of your corp IT data centers do), then use any of the various open utils like mkvirtualenv, etc.

Upvotes: 1

Related Questions