34

运行以下命令

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 二进制文件没有任何区别

4

5 回答 5

22

这似乎是 1.8.4 中的回归。在我的系统上尝试这个时,virtualenv 1.8.2 一切正常,然后我升级了,现在我得到了和你一样的错误。

于 2012-11-27T06:54:59.390 回答
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
于 2014-04-16T18:41:15.230 回答
1

windows对我有用:


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

于 2020-01-28T07:12:31.163 回答
-1

使用 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.

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

于 2016-01-31T04:47:25.067 回答
-1

我得到了解决方案只需使用 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 <folder_name> 不需要使用python -m

于 2021-07-26T08:02:53.707 回答