简体   繁体   English

如何用pypy创建virtualenv?

[英]how to create virtualenv with pypy?

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.我正在使用 CPython 2.7.3 运行 Mac OS X 10.8.1(Mountain Lion)并使用 Brew 安装 pypy 1.9。 virtualenv's version is 1.8.4 virtualenv 的版本是 1.8.4

Using pre-built pypy binary for Mac OS X downloaded directly from pypy's website doesn't make any difference使用直接从 pypy 网站下载的适用于 Mac OS X 的预构建 pypy 二进制文件没有任何区别

This appears to be a regression in 1.8.4.这似乎是 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.在我的系统上尝试这个时,virtualenv 1.8.2 一切正常,然后我升级了,现在我遇到了和你一样的错误。

对于windows这对我有用:


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

I got the same error on Windows using virtualenv 1.8.2.我在使用 virtualenv 1.8.2 的 Windows 上遇到了同样的错误。 Also similar problems with 1.9 and 1.10. 1.9 和 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

With pypy-4.0.1 and virtualenv 14.0.3, out of the box I get an error:使用 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.

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

I got the solution Just use pypy3.exe instead of pypy.exe there are two .exe in downloaded folder我得到了解决方案只需使用 pypy3.exe 而不是 pypy.exe 下载的文件夹中有两个 .exe

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.默认情况下,python 带有 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但是 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