在OS X上使用virtualenv创建虚拟环境时的问题

1 投票
1 回答
587 浏览
提问于 2025-04-16 00:47

我不太确定我的问题是什么。我在尝试配置一个虚拟环境时,遇到了这个错误:

20:59:51 $ virtualenv test -p /usr/local/bin/python

Running virtualenv with interpreter /usr/local/bin/python
New python executable in test/bin/python
Please make sure you remove any previous custom paths from your /Users/nlang/.pydistutils.cfg file.
Overwriting test/lib/python2.6/distutils/__init__.py with new content
Installing setuptools...............done.
  Complete output from command /Users/nlang/Code/Python/venvs...ython /Users/nlang/Code/Python/venvs...stall /Library/Python/2.6/site-packa...ar.gz:
  /Users/nlang/Code/Python/venvs/test/bin/python: can't open file '/Users/nlang/Code/Python/venvs/test/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/virtualenv-1.4.9-py2.6.egg/virtualenv.py", line 1489, in <module>
    main()
  File "/Library/Python/2.6/site-packages/virtualenv-1.4.9-py2.6.egg/virtualenv.py", line 526, in main
    use_distribute=options.use_distribute)
  File "/Library/Python/2.6/site-packages/virtualenv-1.4.9-py2.6.egg/virtualenv.py", line 618, in create_environment
    install_pip(py_executable)
  File "/Library/Python/2.6/site-packages/virtualenv-1.4.9-py2.6.egg/virtualenv.py", line 390, in install_pip
    filter_stdout=_filter_setup)
  File "/Library/Python/2.6/site-packages/virtualenv-1.4.9-py2.6.egg/virtualenv.py", line 587, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/nlang/Code/Python/venvs...ython /Users/nlang/Code/Python/venvs...stall /Library/Python/2.6/site-packa...ar.gz failed with error code 2

我在各种论坛和谷歌上搜索过,但还是没能成功创建一个虚拟环境。我现在卡住了 :(

谢谢

1 个回答

0

从你提供的输出信息来看,具体情况有点难以判断,但看起来你是在尝试更新一个已经存在的虚拟环境(注意到有Overwriting的提示)。首先,确认一下/usr/local/bin/python这个路径下的Python能正常工作。然后,试着在一个新的(不存在的)文件夹里创建一个虚拟环境(不要用test这个名字)。如果这样还是不行,请更新你的问题,添加这两个操作的输出结果。

撰写回答