2012-11-27 59 views
26

运行以下命令如何用pypy创建virtualenv?

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(山狮),并用啤酒安装pypy 1.9。 virtualenv中的版本是1.8.4

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

+0

我在OS X上遇到了同样的错误,并且与您有相同版本的pypy和virtualenv(也从自制软件中安装了pypy) – hasen

回答

22

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

+3

我在https://github.com/pypa/virtualenv/上提交了一个错误报告问题/ 366 –

+2

我降级到1.8.2,它工作!谢谢! 因为这是一个答案我认为你应该提到*如何*降级到1.8.2'''sudo pip install virtualenv == 1.8.2''' – hasen

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 
+0

我已经证实这适用于Windows7的PyPy 2.2.0。唯一的区别是activate位于bin子目录而不是Scripts子目录 –

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. 

搜索原pypy安装UserDict*,我发现UserDict.pylib-python\2.7但在virtualenv的lib-python\2.7只有userdict.py而且没有大写的User文件。以其他解决方案为例,我删除了virtualenv的userdict.py并复制了原始User*文件,并重新命令virtualenv命令,并且运行时没有错误。