3

我有 Mountain Lion,我使用这种方法安装了 virtualenv:

sudo easy_install pip
sudo pip install virtualenv virtualenvwrapper
echo "export WORKON_HOME=$HOME/Envs" >> $BASH_CONFIG_FILE
echo "source /usr/local/bin/virtualenvwrapper.sh" >> $BASH_CONFIG_FILE
source ~/.bashrc

当我尝试使用以下命令创建 virtualenv 时出现问题:

mkvirtualenv test

我收到此错误:

New python executable in test/bin/python
Installing setuptools...........
Complete output from command /Users/marco/Envs/test/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])

" /Library/Python/2.7/...ols-0.6c11-py2.7.egg:
Traceback (most recent call last):
File "<string>", line 279, in <module>
File "<string>", line 207, in main
File "/Library/Python/2.7/site-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/__init__.py", line 2, in <module>
File "/Library/Python/2.7/site-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/extension.py", line 1, in <module>
File "/Users/marco/Envs/test/lib/python2.7/distutils/__init__.py", line 16, in <module>
exec(open(os.path.join(distutils_path, '__init__.py')).read())
IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/__init__.py'
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.7.2', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 942, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1052, in create_environment
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 598, in install_setuptools
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 570, in _install_req
cwd=cwd)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1020, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/marco/Envs/test/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" /Library/Python/2.7/...ols-0.6c11-py2.7.egg failed with error code 1

你能帮助我吗?

谢谢!标记

4

2 回答 2

4

您没有安装 setuptools,

这里安装

如果您从 lion 升级到山狮,由于文件系统的一些更改,python 安装会中断,理想情况下,您应该从 xcode 安装命令行工具,然后从 python 网站安装 python,然后从 python 网站安装 setuptools,然后通过 easy_install 安装 pip ,之后一切都会正常进行。

于 2012-08-19T14:12:17.050 回答
1

问题解决了:

Xcode 4 不会自动安装命令行工具。

基本上,安装 Xcode,进入首选项,然后下载并安装“命令行工具”。现在可以了。

:)

于 2012-08-20T09:35:39.907 回答