无法在Lion中创建新的Virtualenv

时间:2011-08-25 16:57:56

标签: virtualenv osx-lion pip

我在Lion的virtualenv遇到了麻烦。我已经清理了重新安装的Virtualenv和Pip它,但似乎在创建一个新环境时正在努力寻找Pip。我删除了virtualenvwrapper以确保它不会干扰。

不幸的是,它正在查看的路径似乎在错误消息中被截断。

环境已创建部分,但没有激活脚本。这是追溯:

Apollos-Mac-mini:~ apollo$ virtualenv test
New python executable in test/bin/python
Installing setuptools............done.
Installing pip.............
  Complete output from command /Users/apollo/test/bin/python /Users/apollo/test/bin/easy_install /Library/Python/2.7/...ort/pip-1.0.2.tar.gz:
  Processing pip-1.0.2.tar.gz
Running pip-1.0.2/setup.py -q bdist_egg --dist-dir /var/folders/61/08st3n995qn_w6rsjqgv1cx00000gn/T/easy_install-Za9IA8/pip-1.0.2/egg-dist-tmp-lyVJEQ
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
warning: build_py: byte-compiling is disabled, skipping.

warning: install_lib: byte-compiling is disabled, skipping.

error: byte-compiling is disabled.
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 8, in <module>
    load_entry_point('virtualenv==1.6.4', 'console_scripts', 'virtualenv')()
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 810, in main
    never_download=options.never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 912, in create_environment
    install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 648, in install_pip
    filter_stdout=_filter_setup)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 878, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/apollo/test/bin/python /Users/apollo/test/bin/easy_install /Library/Python/2.7/...ort/pip-1.0.2.tar.gz failed with error code 1

3 个答案:

答案 0 :(得分:3)

蒂姆:你可能从我在这个链接上看到的内容正确 - https://bitbucket.org/tarek/distribute/issue/168/easy_install-fails-with-byte-compiling

在链接的末尾还有另一个有趣的注释,您可能想要查看。它说 “设置导出VIRTUALENV_USE_DISTRIBUTE = 1解决了问题。”

我建议您使用分发来安装软件包,因为它似乎比传统的setuptools少了很多麻烦。使用 - 分发选项,如下所示: -

# Not using distribute, uses setuptools
$ virtualenv test1
New python executable in test1/bin/python
Installing setuptools............done.
Installing pip...............done.

# Using distribute by specifying the option
$ virtualenv --distribute test2 
New python executable in test2/bin/python
Installing distribute.....................................................................................................................................................................................done.
Installing pip...............done.

无论如何,很高兴你解决了自己的问题! : - )

答案 1 :(得分:3)

当您在Python中禁用字节编译(.pyc文件)时,easy_install无法正常工作。我在我的开发机器上做了这个,因为当我删除原始.py时,由于.pyc文件被使用,我一直在努力克服错误。

为了纠正这个问题,我删除了

export PYTHONDONTWRITEBYTECODE=1 

来自~/.profile

calvinx的回答也通过使用distribute而不是easy_install来解决这个问题。我认为这两个答案都可以被认为是正确的,但是calvinx允许你继续禁用字节编译,所以我会将其标记为正确。

答案 2 :(得分:1)

我解决了它只是删除了所有的.pyc文件