[Solved]: ERROR: virtualenv is not compatible with this system or executable



When I hit this:

$ virtualenv --system-site-packages -p python3 ./venv

OUTPUT:

Running virtualenv with interpreter /anaconda3/bin/python3Using base prefix '/anaconda3'New python executable in /Users/admin/venv/bin/python3Not overwriting existing python script /Users/admin/venv/bin/python (you must use /Users/admin/venv/bin/python3)dyld: Library not loaded: @rpath/libpython3.6m.dylib  Referenced from: /Users/admin/venv/bin/python3  Reason: image not foundERROR: The executable /Users/admin/venv/bin/python3 is not functioningERROR: It thinks sys.prefix is '/Users/admin' (should be '/Users/admin/venv')ERROR: virtualenv is not compatible with this system or executable

Solution: 2 possible problems can be:

  1. Your python interpreter and packages are managed under Anaconda using Conda package manager, and your virtualenv was originally installed using pip.
  2. You don’t have virtualenv installed.

Uninstalling virtualenv with pip and re-installing with conda fixed the issue:

pip uninstall virtualenvconda install virtualenv

If you’re Getting this Error:

ERROR conda.core.link:_execute(502): An error occurred while installing package 'defaults::virtualenv-16.0.0-py36_0'.

then put sudo:

sudo conda install virtualenv



Final Output:

$ sudo conda install virtualenvSolving environment: done## Package Plan ##  environment location: /anaconda3  added / updated specs:     - virtualenvThe following NEW packages will be INSTALLED:    virtualenv: 16.0.0-py36_0Proceed ([y]/n)? yPreparing transaction: doneVerifying transaction: doneExecuting transaction: done