37

running the following command

virtualenv -p /usr/local/bin/pypy pypy

exits with error like

Running virtualenv with interpreter /usr/local/bin/pypy
New pypy executable in pypy/bin/pypy
debug: WARNING: Library path not found, using compiled-in sys.path.
debug: WARNING: 'sys.prefix' will not be set.
debug: WARNING: Make sure the pypy binary is kept inside its tree of files.
debug: WARNING: It is ok to create a symlink to it from somewhere else.
'import site' failed
AttributeError: 'module' object has no attribute 'prefix'
ERROR: The executable pypy/bin/pypy is not functioning
ERROR: It thinks sys.prefix is u'/Users/myname' (should be u'/Users/myname/pypy')
ERROR: virtualenv is not compatible with this system or executable

I'm running Mac OS X 10.8.1 (Mountain Lion) with CPython 2.7.3 and installed pypy 1.9 using Brew. virtualenv's version is 1.8.4

Using pre-built pypy binary for Mac OS X downloaded directly from pypy's website doesn't make any difference

minorblend
  • 905
  • 1
  • 10
  • 23
  • I'm getting the same error on OS X and have the same versions of pypy and virtualenv as you (also installed pypy from homebrew) – hasen Nov 28 '12 at 02:22

5 Answers5

22

This appears to be a regression in 1.8.4. While trying this out on my system everything worked fine with virtualenv 1.8.2, then I upgraded and now I get the same error as you.

Michael Merickel
  • 23,153
  • 3
  • 54
  • 70
  • 3
    I downgraded to 1.8.2 and it worked! Thanks! Since this is an answer I think you should mention *how to* downgrade to 1.8.2 ```sudo pip install virtualenv==1.8.2``` – hasen Nov 28 '12 at 02:32
1

I got the same error on Windows using virtualenv 1.8.2. Also similar problems with 1.9 and 1.10. What worked for me was to run it once to make the directory, copy missing files, then run again to complete it.

virtualenv -p c:\bin\pypy\pypy.exe pypy
copy c:\bin\pypy\lib_pypy \virtualenvs\pypy
copy c:\bin\pypy\lib-python \virtualenvs\pypy
virtualenv -p c:\bin\pypy\pypy.exe pypy
Ch.Idea
  • 578
  • 6
  • 8
DaveSawyer
  • 351
  • 4
  • 8
  • I have confirmed this works on Windows7 for PyPy 2.2.0. The only difference is activate is located in bin sub-directory rather than the Scripts sub-directory – Kyle Lahnakoski Oct 15 '14 at 14:18
1

For windows this worked for me :


python -m virtualenv -p <Your PYPY installed path\pypy3.exe> <venv_name>

Viraj Wadate
  • 5,447
  • 1
  • 31
  • 29
0

I got the solution Just use pypy3.exe instead of pypy.exe there are two .exe in downloaded folder

virtualenv -p C:/pypy3.7-v7.3.5-win64/pypy3.7-v7.3.5-win64/pypy3w.exe <folder_name>

By default python comes with venv. But venv has no -p Install virtualenv using pip Then use direct virtualenv -p path/pypy3.exe <folder_name> no need to use python -m

Ohm Dios
  • 43
  • 1
  • 5
-1

With pypy-4.0.1 and virtualenv 14.0.3, out of the box I get an error:

Q:\>c:\pypy\bin\virtualenv -p c:\pypy\pypy.exe my_pypy_virtualenv
Already using interpreter c:\pypy\pypy.exe
New pypy executable in Q:\my_pypy_virtualenv\bin\pypy.exe
debug: OperationError:
debug:  operror-type: ImportError
debug:  operror-value: No module named UserDict
ERROR: The executable Q:\my_pypy_virtualenv\bin\pypy.exe is not functioning
ERROR: It thinks sys.prefix is u'q:\\' (should be u'q:\\my_pypy_virtualenv')
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 versions of Python installed. Copying the appropriate PythonXX.dll to the virtualenv Scripts/ directory may fix this problem.

Searching the original pypy install for UserDict*, I found UserDict.py in lib-python\2.7 but in the virtualenv's lib-python\2.7 there was only userdict.py and none of the capitalized User files. Following the example of the other solutions, I removed the virtualenv's userdict.py and copied the original User* files, and reran the virtualenv command, and it ran without error.

rakslice
  • 8,742
  • 4
  • 53
  • 57