如何用pypy创建virtualenv?

时间:2012-11-27 06:32:29

标签: python virtualenv pypy

运行以下命令

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

退出时出现错误,如

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

我正在使用CPython 2.7.3运行Mac OS X 10.8.1(Mountain Lion)并使用Brew安装pypy 1.9。 virtualenv的版本是1.8.4

使用直接从pypy网站下载的Mac OS X预构建的pypy二进制文件没有任何区别

5 个答案:

答案 0 :(得分:22)

这似乎是1.8.4的回归。在我的系统上尝试这一切时,一切都运行良好的virtualenv 1.8.2,然后我升级,现在我得到了与你相同的错误。

答案 1 :(得分:1)

我在使用virtualenv 1.8.2的Windows上遇到了同样的错误。 1.9和1.10也有类似的问题。对我有用的是运行一次以创建目录,复制丢失的文件,然后再次运行以完成它。

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

答案 2 :(得分:1)

对于windows,这对我有用:


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

答案 3 :(得分:0)

使用pypy-4.0.1和virtualenv 14.0.3,开箱即可出现错误:

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.

搜索UserDict*的原始pypy安装,我在UserDict.py中找到lib-python\2.7但在virtualenv的lib-python\2.7中只有userdict.py且没有大写User个文件。按照其他解决方案的示例,我删除了virtualenv的userdict.py并复制了原始的User*文件,然后重新运行virtualenv命令,它运行时没有错误。

答案 4 :(得分:0)

我得到了解决方案 只需使用 pypy3.exe 而不是 pypy.exe 下载文件夹中有两个 .exe

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

默认情况下,python 带有 venv。但是 venv 没有 -p 使用 pip 安装 virtualenv 然后直接使用 virtualenv -p path/pypy3.exe 无需使用 python -m