繁体   English   中英

如何用pypy创建virtualenv?

[英]how to create virtualenv with 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 二进制文件没有任何区别

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

对于windows这对我有用:


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

我在使用 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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM