在尝试设置virtualenv时,为什么会出现此错误(与pip和easy_install相关)?

时间:2013-01-08 21:30:11

标签: python flask virtualenv pip easy-install

我正在尝试创建一个Flask应用程序来推送到Heroku。当我尝试在文件夹中创建virtualenv时,我抛出了这个错误:

photo-crawl › sudo virtualenv venv --distribute
Password:
New python executable in venv/bin/python
Installing distribute............................................................................................................................................................................................................................done.
Installing pip....
  Complete output from command /Users/evansiegel/In...rawl/venv/bin/python -x /Users/evansiegel/In...env/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz:
  /Users/evansiegel/Involvio/photo-crawl/venv/bin/python: can't open file '/Users/evansiegel/Involvio/photo-crawl/venv/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==1.8.4', 'console_scripts', 'virtualenv')()
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 964, in main
    never_download=options.never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 1076, 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 667, in install_pip
    filter_stdout=_filter_setup)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 1042, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/evansiegel/In...rawl/venv/bin/python -x /Users/evansiegel/In...env/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz failed with error code 2

似乎由于某种原因virtualenv没有将它应该放入venv/bin文件夹中的所有内容。目前,只有python和两个别名python2python2.7在那里。

谢谢!

1 个答案:

答案 0 :(得分:4)

我认为这是由旧版virtualenv和/或pip中的错误引起的。看起来你正在使用virtualenv 1.8.4和pip 1.2.1。你有可能升级到最新的virtualenv和pip(目前是virtualenv 1.9.1和pip 1.3.1)吗?

如果你有安装权限,这应该这样做:

pip install pip --upgrade
pip install virtualenv --upgrade

此时运行相同的命令(即sudo virtualenv venv --distribute)应该会给你你想要的东西。