如何使用pypy创建virtualenv?

问题描述 投票:0回答:5

运行以下命令

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

python virtualenv pypy
5个回答
22
投票

这似乎是 1.8.4 中的回归。在我的系统上尝试此操作时,virtualenv 1.8.2 一切正常,然后我升级了,现在我得到了与您相同的错误。


1
投票

对于

windows
这对我有用:

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

1
投票

我在 Windows 上使用 virtualenv 1.8.2 遇到了同样的错误。 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

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 <folder_name>
无需使用
python -m


-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安装中搜索

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

© www.soinside.com 2019 - 2024. All rights reserved.