Error virtualenv is not compatible with this system or executable

Simply trying to create a virtual environment on my mac OSX 10.10.05 Running from the Terminal, already successfully made VirtualEnv on linux and windows OS on other computers. Tried troubleshoot...

Simply trying to create a virtual environment on my mac OSX 10.10.05

Running from the Terminal, already successfully made VirtualEnv on linux and windows OS on other computers.

Tried troubleshooting this by adding a WORK_ON path to my bash profile, did not resolve. Online forums doesn’t seem to address this, suggestions are to use mkvirtualenv which does not seem to be a downloadable package per pip, conda and easy_install…

Anyways, if you’re able to help that would be super appreciated.

here’s the terminal output:

joshua ~ $ pip install --upgrade virtualenv
Requirement already up-to-date: virtualenv in ./anaconda/lib/python3.5/site-packages
joshua ~ $ virtualenv -p python3 test
Running virtualenv with interpreter /Users/joshua/anaconda/bin/python3
Using base prefix '/Users/joshua/anaconda'
New python executable in /Users/joshua/test/bin/python3
Also creating executable in /Users/joshua/test/bin/python
ERROR: The executable /Users/joshua/test/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/Users/joshua' (should be '/Users/joshua/test')
ERROR: virtualenv is not compatible with this system or executable

…tried uninstalling virtualenv

  Successfully uninstalled virtualenv-15.1.0
joshua ~ $ pip install virtualenv
Collecting virtualenv
  Using cached virtualenv-15.1.0-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
joshua ~ $ virtualenv test -v
Using base prefix '/Users/joshua/anaconda'
Creating /Users/joshua/test/lib/python3.5
Symlinking Python bootstrap modules
  Symlinking /Users/joshua/test/lib/python3.5/config-3.5m
  Symlinking /Users/joshua/test/lib/python3.5/lib-dynload
  Symlinking /Users/joshua/test/lib/python3.5/plat-darwin
  Symlinking /Users/joshua/test/lib/python3.5/os.py
  Ignoring built-in bootstrap module: posix
  Symlinking /Users/joshua/test/lib/python3.5/posixpath.py
  Cannot import bootstrap module: nt
  Symlinking /Users/joshua/test/lib/python3.5/ntpath.py
  Symlinking /Users/joshua/test/lib/python3.5/genericpath.py
  Symlinking /Users/joshua/test/lib/python3.5/fnmatch.py
  Symlinking /Users/joshua/test/lib/python3.5/locale.py
  Symlinking /Users/joshua/test/lib/python3.5/encodings
  Symlinking /Users/joshua/test/lib/python3.5/codecs.py
  Symlinking /Users/joshua/test/lib/python3.5/stat.py
  Cannot import bootstrap module: UserDict
  Cannot import bootstrap module: copy_reg
  Symlinking /Users/joshua/test/lib/python3.5/types.py
  Symlinking /Users/joshua/test/lib/python3.5/re.py
  Cannot import bootstrap module: sre
  Symlinking /Users/joshua/test/lib/python3.5/sre_parse.py
  Symlinking /Users/joshua/test/lib/python3.5/sre_constants.py
  Symlinking /Users/joshua/test/lib/python3.5/sre_compile.py
  Cannot import bootstrap module: _abcoll
  Symlinking /Users/joshua/test/lib/python3.5/warnings.py
  Symlinking /Users/joshua/test/lib/python3.5/linecache.py
  Symlinking /Users/joshua/test/lib/python3.5/abc.py
  Symlinking /Users/joshua/test/lib/python3.5/io.py
  Symlinking /Users/joshua/test/lib/python3.5/_weakrefset.py
  Symlinking /Users/joshua/test/lib/python3.5/copyreg.py
  Symlinking /Users/joshua/test/lib/python3.5/tempfile.py
  Symlinking /Users/joshua/test/lib/python3.5/random.py
  Symlinking /Users/joshua/test/lib/python3.5/__future__.py
  Symlinking /Users/joshua/test/lib/python3.5/collections
  Symlinking /Users/joshua/test/lib/python3.5/keyword.py
  Symlinking /Users/joshua/test/lib/python3.5/tarfile.py
  Symlinking /Users/joshua/test/lib/python3.5/shutil.py
  Symlinking /Users/joshua/test/lib/python3.5/struct.py
  Symlinking /Users/joshua/test/lib/python3.5/copy.py
  Symlinking /Users/joshua/test/lib/python3.5/tokenize.py
  Symlinking /Users/joshua/test/lib/python3.5/token.py
  Symlinking /Users/joshua/test/lib/python3.5/functools.py
  Symlinking /Users/joshua/test/lib/python3.5/heapq.py
  Symlinking /Users/joshua/test/lib/python3.5/bisect.py
  Symlinking /Users/joshua/test/lib/python3.5/weakref.py
  Symlinking /Users/joshua/test/lib/python3.5/reprlib.py
  Symlinking /Users/joshua/test/lib/python3.5/base64.py
  Symlinking /Users/joshua/test/lib/python3.5/_dummy_thread.py
  Symlinking /Users/joshua/test/lib/python3.5/hashlib.py
  Symlinking /Users/joshua/test/lib/python3.5/hmac.py
  Symlinking /Users/joshua/test/lib/python3.5/imp.py
  Symlinking /Users/joshua/test/lib/python3.5/importlib
  Symlinking /Users/joshua/test/lib/python3.5/rlcompleter.py
  Symlinking /Users/joshua/test/lib/python3.5/operator.py
  Symlinking /Users/joshua/test/lib/python3.5/_collections_abc.py
  Symlinking /Users/joshua/test/lib/python3.5/_bootlocale.py
Creating /Users/joshua/test/lib/python3.5/site-packages
Writing /Users/joshua/test/lib/python3.5/site.py
Writing /Users/joshua/test/lib/python3.5/orig-prefix.txt
Writing /Users/joshua/test/lib/python3.5/no-global-site-packages.txt
Creating parent directories for /Users/joshua/test/include
Symlinking /Users/joshua/test/include/python3.5m
Creating /Users/joshua/test/bin
New python executable in /Users/joshua/test/bin/python
Changed mode of /Users/joshua/test/bin/python to 0o755
Testing executable with /Users/joshua/test/bin/python -c "import sys;out=sys.stdout;getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))"
ERROR: The executable /Users/joshua/test/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/joshua' (should be '/Users/joshua/test')
ERROR: virtualenv is not compatible with this system or executable

here’s current bash_profile:

# Enable tab completion
source ~/git-completion.bash

# colors!
green="[33[0;32m]"
blue="[33[0;34m]"
purple="[33[0;35m]"
reset="[33[0m]"

# Change command prompt
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# 'u' adds the name of the current user to the prompt
# '$(__git_ps1)' adds git-related stuff
# 'W' adds the name of the current directory
export PS1="$purpleu$green$(__git_ps1)$blue W $ $reset"

alias subl="/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"

# Add Path
export PATH="$HOME/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH"
# export PATH=$PATH:/users/Joshua/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

# Locale 
$ export LC_ALL=en_US.UTF-8
$ export LANG=en_US.UTF-8

@ivf777

I deleted old virtualenv «my3» with command
rmvirtualenv my3

and I created new virtualenv with command
mkvirtualenv my3 -p python3

I have 3 errors:

Running virtualenv with interpreter /home/myname/anaconda3/bin/python3
Using base prefix ‘/home/myname/anaconda3’
New python executable in /home/myname/.virtualenvs/my3/bin/python3
Also creating executable in /home/myname/.virtualenvs/my3/bin/python
/home/myname/.virtualenvs/my3/bin/python3: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable /home/myname/.virtualenvs/my3/bin/python3 is not functioning
ERROR: It thinks sys.prefix is ‘/home/myname/.virtualenvs’ (should be ‘/home/myname/.virtualenvs/my3’)
ERROR: virtualenv is not compatible with this system or executable

What can I do to create new virtualenv «my3»?

P.S.
I have Ubuntu 16.04

@gst

For python3 it s recommended to use venv module. It s builtin in python3.

@altendky

Recommended by some. Others like the 2/3 compatibility and separation from core of virtualenv.

But, is this a dup of #1050? Also, isn’t conda what anaconda provides as an alternative?

@yazabaza

I have the same issue on Mac OS 10.12.6 and virtualenv 15.1.0:

RonMacAir-4:~ r$ virtualenv --system-site-packages /Users/r/tf13py27
Using base prefix '/Users/r/anaconda'
New python executable in /Users/r/tf13py27/bin/python
dyld: Library not loaded: @rpath/libpython3.6m.dylib
  Referenced from: /Users/r/tf13py27/bin/python
  Reason: image not found
ERROR: The executable /Users/r/tf13py27/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/r' (should be '/Users/r/tf13py27')
ERROR: virtualenv is not compatible with this system or executable

I suspect this is due to the Anaconda installation changing the system python interpreter path to point to the Anaconda python binary, then virtualenv tries to install from there rather than the original system python binary.

@altendky

@yazabaza maybe try specifying the python executable you want to use via -p. It looks like it’s now using your Anaconda Python instead of whatever you had before based on the base prefix given.

@yazabaza

Yes, pointing to the original python interpreter fixed it. Thanks!

@wizardboy2010

I used this in ubuntu
virtualenv --system-site-packages -p python3 ~/tensorflow

my error is
Running virtualenv with interpreter /home/user/anaconda3/bin/python3
Using base prefix '/home/user/anaconda3'
New python executable in /home/user/tensorflow/bin/python3
Also creating executable in /home/user/tensorflow/bin/python
/home/user/tensorflow/bin/python3: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable /home/user/tensorflow/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/home/user' (should be '/home/user/tensorflow')
ERROR: virtualenv is not compatible with this system or executable

How to overcome this

@altendky

@wizardboy2010 are you trying to use virtualenv with your anaconda python? If so, I thought conda was meant for envs with anaconda. If not, it’s finding your anaconda python and you need to specify your regular system python instead. Anaconda seems to have put itself earlier in the $PATH so python3 points to it.

@everttrollip

If you are still struggling, and experiencing this issue:

ERROR: virtualenv is not compatible with this system or executable

Have you tried installing virtualenv with conda and trying again?

conda install virtualenv

FourSpaces, Stuip, ItamarF, lavenderLatte, daa233, parulnith, nslatysheva, AbhimanyuAryan, hchungdelta, PapaMadeleine2022, and 12 more reacted with thumbs up emoji
PapaMadeleine2022, FourSpaces, sirius0503, and HackerEunji reacted with laugh emoji
PapaMadeleine2022 and FourSpaces reacted with hooray emoji
PapaMadeleine2022 and FourSpaces reacted with heart emoji

@FourSpaces

I also encountered this problem, my environment is anaconda python,
Uninstall virtualenv using pip, install virtualenv using conda,
pip uninstall virtualenv
conda install virtualenv
Virtualenv can be used normally

rogribas, ItamarF, fureigh, yanjingcui, ezavarygin, galinaalperovich, kanderson102, prezaei85, wscheep, AkihiroIshii, and 33 more reacted with thumbs up emoji
abdou31 and eigenein reacted with thumbs down emoji
hangweiqiang, PapaMadeleine2022, FourSpaces, anujith-singh, and YuetongY reacted with laugh emoji
PapaMadeleine2022, zhuguotian, aliiinos, FourSpaces, and Sushil-Thapa reacted with hooray emoji
PapaMadeleine2022, FourSpaces, mozack, atreyhazelhispanic, lina-kim, jking777, and rafulll reacted with heart emoji

@vesellov

in my venv/lib/python3.6/site-packages/virtualenv.py after line 1118 i added: prefix = os.path.abspath(prefix) and it started working on my MacOS Sierra

@axiaoxin

I ceate virtualenv in a dir which named like test.2018-08-13_20:16:01 will fail, normal dir name is ok.

New python executable in /data/srv/test.2018-08-13_20:16:01/test/bin/python
ImportError: No module named site
ERROR: The executable /data/srv/test.2018-08-13_20:16:01/test/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/data/srv/test.2018-08-13_20:16:01' (should be u'/data/srv/test.2018-08-13_20:16:01/test')
ERROR: virtualenv is not compatible with this system or executable

anthrotype

added a commit
to anthrotype/fonttools
that referenced
this issue

Sep 12, 2018

@anthrotype

anthrotype

added a commit
to anthrotype/fonttools
that referenced
this issue

Sep 12, 2018

@anthrotype

formula is now named just 'python'.
For the homebrew version installed on Travis (which we don't
autoupdate) we *should* get python3.6 with this currently.

It might be the case that python3 is already installed on
Travis macOS image, but need to check.

We call tox with 'TOXENV=py3' so that when Travis updates its homebrew,
we'll get python3.7 automatically.

Finally, use virtualenv instead of venv on mac to fix tox bootstrapping issue

pypa/virtualenv#1051
pre-commit/pre-commit#631
https://travis-ci.org/fonttools/fonttools/jobs/427582922#L214

fixup

@stale

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.

@jandog8990

So I’m having the same problem but I don’t think it’s an Anaconda thing, I’ve installed Py3.5 standalone with the latest pip and virtualenv and I get the following errs:

Running virtualenv with interpreter /usr/bin/python
Using base prefix ‘/System/Library/Frameworks/Python.framework/Versions/3.5’
New python executable in ///PythonInstalls/venv/bin/python
ERROR: The executable ///PythonInstalls/venv/bin/python is not functioning
ERROR: It thinks sys.prefix is ‘/System/Library/Frameworks/Python.framework/Versions/3.5’ (should be ‘///PythonInstalls/venv’)
ERROR: virtualenv is not compatible with this system or executable

Has anyone solved this without the need for Anaconda? That’s a whole set of probs I’m not willing to try at the moment

@gaborbernat

Hmm feels like a problem with the system python of Mac. Can you replicate with the brew one, or the official one with python.org?

@jandog8990

@gaborbernat Hey so I finally got it, instead of using virtualenv executable use the pyvenv for Mac users!

$ pyvenv —system-site-packages ./venv

@pypa
pypa

locked and limited conversation to collaborators

Jan 14, 2021

This is an article written to solve the error specified in the title. It is actually an error where the error itself happened upon executing the command ‘virtualenv virtual_environment_name’ as shown below :

root@hostname:/home/user/apps/user# virtualenv projectenv
New python executable in /home/user/apps/user/projectenv/bin/python
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 563, in 
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 582, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 528, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 412, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in 
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd
ERROR: The executable /home/user/apps/user/projectenv/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/home/user/apps/user' (should be u'/home/user/apps/user/projectenv')
ERROR: virtualenv is not compatible with this system or executable
root@hostname:/home/user/apps/user# 

The error is shown as follows :

ERROR: virtualenv is not compatible with this system or executable

The virtual environment basically assumed as the aspect needed to be included in the configuration of Apache Webserver in order to deploy a web-based application powered by Django framework written in Python programming language. The following is considered to be the value of the path where the virtual environment created in Apache Webserver virtual host configuration :

WSGIPythonHome /home/user/apps/user/projectenv

To solve the problem, create a symlink to the python home folder location currently running by executing the following command :

root@hostname:/home/user/apps/user# ln -fs /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata.py /usr/lib/python2.7/
root@hostname:/home/user/apps/user# sudo ln -fs /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py /usr/lib/python2.7/

After executing the command line above, just re-execute the command used to create a virtual environment as shown below :

root@hostname:/home/user/apps/user# virtualenv projectenv
New python executable in /home/user/apps/user/projectenv/bin/python
Installing setuptools, pip, wheel...done.
root@hostname:/home/user/apps/user#

After that, check the content of the folder inside where the command for creating the virtual environment is executed, just to make sure as shown below :

root@hostname:/home/user/apps/user# ls
bin  projectenv  app.sublime-project  app.sublime-workspace  include  lib  local  logs  src  static
You have new mail in /var/mail/root
root@hostname:/home/user/apps/user# 

I’m running Precise Pangolin amd64. I installed Python 3.3 from ppa:fkrull/deadsnakes.

Now I want to actually use this new Python version in a virtualenv. But How can I do this? I get the following error:

$ virtualenv --no-site-packages --distribute -p /usr/bin/python3.3 ~/.virtualenvs/pywork3
Running virtualenv with interpreter /usr/bin/python3.3
The --no-site-packages flag is deprecated; it is now the default behavior.
New python executable in /home2/USERNAME/.virtualenvs/pywork3/bin/python3.3
Also creating executable in /home2/USERNAME/.virtualenvs/pywork3/bin/python
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/site.py", line 73, in <module>
    __boot()
  File "/usr/local/lib/python2.7/site-packages/site.py", line 2, in __boot
    import sys, imp, os, os.path   
ImportError: No module named 'imp'
ERROR: The executable /home2/USERNAME/.virtualenvs/pywork3/bin/python3.3 is not functioning
ERROR: It thinks sys.prefix is '/home2/USERNAME/.virtualenvs' (should be '/home2/USERNAME/.virtualenvs/pywork3')
ERROR: virtualenv is not compatible with this system or executable

If instead, I explicitly use python3.3 to call virtualenv, I get this error:

$ python3.3 /usr/bin/virtualenv --no-site-packages --distribute -p /usr/bin/python3.3 ~/.virtualenvs/pywork3
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 2, in <module>
    import virtualenv
ImportError: No module named 'virtualenv'

I’m stuck. Any help is greatly appreciated!

EDIT: Following the advise by @thefourtheye, I purged my local site-packages directory (effectively only deleting site.py). Now I’m getting a step further, but virtualenv complains about a missing easy_install:

 Error [Errno 2] No such file or directory:   
'/home2/USERNAME/.virtualenvs/pywork3/bin/easy_install' while executing command    
/home2/USERNAME/.virt...rk3/bin/easy_install /usr/share/python-virtualenv/pip-1.1.tar.gz

I did install the package python3-setuptools, which installs the Py3 version of easy_install.

EDIT2:

Here’s the verbose output, without explicitly passing --distribute and --no-site-packages, as these two switches are default behaviour of my virtualenv:

$ virtualenv --verbose -p /usr/bin/python3.3 ~/.virtualenvs/pywork3
Running virtualenv with interpreter /usr/bin/python3.3
Creating /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3
Symlinking Python bootstrap modules
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/config-3.3m
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/lib-dynload
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/os.py
  Ignoring built-in bootstrap module: posix
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/posixpath.py
  Cannot import bootstrap module: nt
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/ntpath.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/genericpath.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/fnmatch.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/locale.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/encodings
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/codecs.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/stat.py
  Cannot import bootstrap module: UserDict
  Cannot import bootstrap module: copy_reg
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/types.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/re.py
  Cannot import bootstrap module: sre
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/sre_parse.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/sre_constants.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/sre_compile.py
  Ignoring built-in bootstrap module: zlib
  Cannot import bootstrap module: _abcoll
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/warnings.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/linecache.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/abc.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/io.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/_weakrefset.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/copyreg.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/tempfile.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/random.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/__future__.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/collections
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/keyword.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/tarfile.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/shutil.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/struct.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/copy.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/base64.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/bisect.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/_dummy_thread.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/hashlib.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/heapq.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/hmac.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/reprlib.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/rlcompleter.py
  Symlinking /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/weakref.py
Creating /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/site-packages
Writing /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/site.py
Writing /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/orig-prefix.txt
Writing /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/no-global-site-packages.txt
Creating parent directories for /home2/USERNAME/.virtualenvs/pywork3/include
Symlinking /home2/USERNAME/.virtualenvs/pywork3/include/python3.3m
Creating /home2/USERNAME/.virtualenvs/pywork3/bin
New python executable in /home2/USERNAME/.virtualenvs/pywork3/bin/python3.3
Changed mode of /home2/USERNAME/.virtualenvs/pywork3/bin/python3.3 to 0o755
Also creating executable in /home2/USERNAME/.virtualenvs/pywork3/bin/python
Changed mode of /home2/USERNAME/.virtualenvs/pywork3/bin/python to 0o755
Testing executable with /home2/USERNAME/.virtualenvs/pywork3/bin/python3.3 -c "
import sys
prefix = sys.prefix
if sys.version_info[0] == 3:
    prefix = prefix.encode('utf8')
if hasattr(sys.stdout, 'detach'):
    sys.stdout = sys.stdout.detach()
elif hasattr(sys.stdout, 'buffer'):
    sys.stdout = sys.stdout.buffer
sys.stdout.write(prefix)
"
Got sys.prefix result: '/home2/USERNAME/.virtualenvs/pywork3'
Creating /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/distutils
Writing /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/distutils/__init__.py
Writing /home2/USERNAME/.virtualenvs/pywork3/lib/python3.3/distutils/distutils.cfg
Using existing distribute egg: /usr/share/python-virtualenv/distribute-0.6.24.tar.gz
Installing distribute..............................................................................................................................................................................................................................................................................................................................................................................................................done.
Installing existing pip-1.1.tar.gz distribution: /usr/share/python-virtualenv/pip-1.1.tar.gz
Installing pip...
  Error [Errno 2] No such file or directory: '/home2/USERNAME/.virtualenvs/pywork3/bin/easy_install' while executing command /home2/USERNAME/.virt...rk3/bin/easy_install /usr/share/python-virtualenv/pip-1.1.tar.gz
...Installing pip...done.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 2283, in <module>
    main()
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 938, in main
    never_download=options.never_download)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1054, in create_environment
    install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 643, in install_pip
    filter_stdout=_filter_setup)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 976, in call_subprocess
    cwd=cwd, env=env)
  File "/usr/lib/python3.3/subprocess.py", line 818, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.3/subprocess.py", line 1416, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/home2/USERNAME/.virtualenvs/pywork3/bin/easy_install'

The idea is that we do not want to install a new version of Python on the system (e.g., for testing purpose), which may interfere with your entire distribution.

Instead, we want to create a virtual environment with virtualenv tool.

Let us assume you have python 2.7 and you want to play with Python 3.4

1. First, the Python executable

cd
mkdir Software
cd Software
wget  https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tar.xz
unxz Python-3.4.1.tar.xz
tar xvf Python-3.4.1.tar
cd Python-3.4.1
./configure --prefix=/home/user/Software/Python-3.4.1/mybuild
make
make install

2. VirtualEnv setup

If you decide to install python3.4 (latest version), make sure you also have the latest version of virtualenv (1.11). I used 1.9 and got this kind of errors:

ImportError: No module named '_collections_abc'
...
ERROR: The executable py34/bin/python3 is not functioning
ERROR: It thinks sys.prefix is ....
ERROR: virtualenv is not compatible with this system or executable

updating virtualenv with

pip install --upgrade virtualenv

fixed the issue.

On another computer, I got this error message:

ImportError: cannot import name 'HTTPSHandler'

which was due to a missing openssl library:

sudo yum install openssl openssl-devel

openssl-devel is the package to install under Fedora. maybe differently named on other distributions.

Let us now create the virtualenv, which is just like a normal directory (let us call it python3)

virtualenv --python=/home/&lt;user&gt;/Software/Python3.4/mybuild/bin/python3.4 virtualenv3
cd virtualenv3

3. Initialise the virtualenv and testing

cd virtualenv3
source bin/activate
python

You should now be able to check the python version to be 3.41

Python 3.4.1 (default, Aug 16 2014, 18:35:43)
[GCC 4.7.2 20120921 (Red Hat 4.7.2-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Please follow and like us:

This entry was posted in Python, Software development and tagged virtualenv. Bookmark the permalink.

Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Chris Nelson

Hello! I’m having a lot of trouble installing virtualenv on windows 8.1.

I’ve installed python locally and used pip install virtualenv, and that all worked fine. But now I’m having issues naming virtualenv to venv? I’m not exactly sure the correct terms so correct me if I’m wrong. I’m not trying to activate it yet because I still need to do the step before it.

In command prompt I’m typing c:python 3.5libvenvvirtualenv venv and it’s not working. I’ve tried several different locations and they all say «The file name, directory name, or volume label syntax is incorrect.»

I’ve tried uninstalling and reinstalling python several times now. Can’t seem to figure it out!

Help would be very appreciated, thanks

7 Answers

Chris Nelson

PS C:Windowssystem32> c:python35libsite-packagesvirtualenv venv
Using base prefix 'C:\Python35'
New python executable in venvScriptspython.EXE
ERROR: The executable venvScriptspython.EXE is not functioning
ERROR: It thinks sys.prefix is 'c:\windows\syswow64\venv' (should be 'c:\windows\system32\venv')
ERROR: virtualenv is not compatible with this system or executable
Note: some Windows users have reported this error when they installed Python for "Only this user" or have multiple versi
ons of Python installed. Copying the appropriate PythonXX.dll to the virtualenv Scripts/ directory may fix this problem.111

Chris Freeman

MOD

The issue is with the directory path name. In some setups, path names with spaces in them, such as «Python 3.5», do not work with all scripts. The best solution would be to re-install Python 3.5 in the directory C:Python3.5 or C:Python35

Chris Nelson

Oooh, I’ve been using command prompt. Not powershell. I had no idea we had to use powershell

Chris Nelson

I’ve changed the execution policy to remote signed, and I get an error when I run PATH:
c:python35libsite-packagesvirtualenv venv. I’m not sure how to copy and post the error though.

It says it creates python.exe in venv/scripts and says that the computer thinks the prefix is one path but should actually be a different one. Then says virtualenv is not compatible with this system or executable.

Chris Nelson

Ah man, I’ll download the right one and re-install. I read somewhere that the 64bit version was buggy. Thanks for your help, I’ll let you know if I have any issues. Just to clerify; should I be running c:python35libsite-packagesvirtualenv venv OR c:python35libvenvvirtualenv venv?

Thank you Chris

Chris Nelson

All sorted Chris, thank you so much.

Chris Nelson

Must have just been the fact I was using 32 bit instead of 64. c:python34scriptsvirtualenv venv and c:python34libsite-packagesvirtualenv venv worked fine either way. Activating it after that was no issue using venvscriptsactivate

I feel like the need for Powershell needs to be stated a bit more, and the changing of the execution policy was smart as well.

Very happy, thank you

Понравилась статья? Поделить с друзьями:
  • Error video footage
  • Error video driver crashed and was reset sea of thieves
  • Error video data loading ivi
  • Error vgacon disables amdgpu kernel modesetting
  • Error vertex file for player zombie mdl checksum 797198640 should be 1815117791