1

我之前遇到了一个问题,试图在我的 virtualenv 中安装 gevent。我尝试了一些不同的东西,包括一些导出命令、安装 XCode 命令行工具、安装 GCC 编译器……这些都不起作用。

在这个过程中,我设法搞砸了我的 virtualenv 安装。我已经删除了 virtualenv 目录并试图重新创建它,但没有运气。我已经卸载并重新安装了 virtualenv(使用 pip),运行以下命令后仍然出现以下错误。

命令:

virtualenv ENV

我想知道为什么它在 /Library 中寻找安装目录。有什么地方可以解决这个问题吗?

更新 v2:删除了虚拟卷饼

使用 --verbose 输出:

Creating ENV/lib/python2.7
Symlinking Python bootstrap modules
Symlinking ENV/lib/python2.7/config
Symlinking ENV/lib/python2.7/lib-dynload
Symlinking ENV/lib/python2.7/os.py
Ignoring built-in bootstrap module: posix
Symlinking ENV/lib/python2.7/posixpath.py
Cannot import bootstrap module: nt
Symlinking ENV/lib/python2.7/ntpath.py
Symlinking ENV/lib/python2.7/genericpath.py
Symlinking ENV/lib/python2.7/fnmatch.py
Symlinking ENV/lib/python2.7/locale.py
Symlinking ENV/lib/python2.7/encodings
Symlinking ENV/lib/python2.7/codecs.py
Symlinking ENV/lib/python2.7/stat.py
Symlinking ENV/lib/python2.7/UserDict.py
Symlinking ENV/lib/python2.7/copy_reg.py
Symlinking ENV/lib/python2.7/types.py
Symlinking ENV/lib/python2.7/re.py
Symlinking ENV/lib/python2.7/sre.py
Symlinking ENV/lib/python2.7/sre_parse.py
Symlinking ENV/lib/python2.7/sre_constants.py
Symlinking ENV/lib/python2.7/sre_compile.py
Symlinking ENV/lib/python2.7/warnings.py
Symlinking ENV/lib/python2.7/linecache.py
Symlinking ENV/lib/python2.7/_abcoll.py
Symlinking ENV/lib/python2.7/abc.py
Symlinking ENV/lib/python2.7/_weakrefset.py
Creating ENV/lib/python2.7/site-packages
Writing ENV/lib/python2.7/site.py
Writing ENV/lib/python2.7/orig-prefix.txt
Writing ENV/lib/python2.7/no-global-site-packages.txt
Creating parent directories for ENV/include
Symlinking ENV/include/python2.7
Creating ENV/bin
New python executable in ENV/bin/python
Changed mode of ENV/bin/python to 0755
Symlinking ENV/.Python
Testing executable with ENV/bin/python -c "import sys;out=sys.stdout;getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))"
Got sys.prefix result: u'/Users/aharwood/Documents/SUCode/mds-item-read-svc/ENV'
Creating ENV/lib/python2.7/distutils
Writing ENV/lib/python2.7/distutils/__init__.py
Writing ENV/lib/python2.7/distutils/distutils.cfg
Using existing setuptools egg: /Library/Python/2.7/site-packages/virtualenv-1.9.1-py2.7.egg/virtualenv_support/setuptools-0.6c11-py2.7.egg
Installing setuptools...
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
  [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-3535.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
  /Library/Python/2.7/site-packages/
Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
  http://peak.telecommunity.com/EasyInstall.html
Please make the appropriate changes for your system and try again.
Complete output from command /Users/aharwood/Docu...d-svc/ENV/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])






" /Library/Python/2.7/...ols-0.6c11-py2.7.egg:
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-3535.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/Library/Python/2.7/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

http://peak.telecommunity.com/EasyInstall.html

Please make the appropriate changes for your system and try again.

----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.9.1', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv-1.9.1-py2.7.egg/virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "/Library/Python/2.7/site-packages/virtualenv-1.9.1-py2.7.egg/virtualenv.py", line 1091, in create_environment
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv-1.9.1-py2.7.egg/virtualenv.py", line 611, in install_setuptools
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv-1.9.1-py2.7.egg/virtualenv.py", line 583, in _install_req
cwd=cwd)
File "/Library/Python/2.7/site-packages/virtualenv-1.9.1-py2.7.egg/virtualenv.py", line 1057, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/aharwood/Docu...d-svc/ENV/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])






" /Library/Python/2.7/...ols-0.6c11-py2.7.egg failed with error code 1

更新v3:我发现了我为尝试安装 gevent 所做的一件事。这会导致我的问题吗?

sudo port install libevent
CFLAGS="-I /opt/local/include -L /opt/local/lib" pip install gevent
4

1 回答 1

0

这条线看起来很可疑:

Using existing setuptools egg: /Users/aharwood/.venvburrito/lib/python/virtualenv-1.9.1-py2.7.egg/virtualenv_support/setuptools-0.6c11-py2.7.egg

你在积极使用virtualenv-burrito吗?我不确定它到底做了什么,但是查看安装文件会改变你的 shell 的启动命令,这可能会导致你的问题。

我会尝试将其移开,打开一个新的终端窗口,然后查看运行 virtualenv 是否再次正常工作:

mv ~/.venvburrito ~/.venvburrito.disabled

如果这样可以解决您的问题,您可以更永久地将其删除:

rm -fr ~/.venvburrito.disabled

它还在这些文件之一中安装了一些代码(取决于您的 shell):

~/.bash_profile
~/.zprofile
~/.profile

您可以删除该代码,但如果您将其保留,它看起来不会造成任何问题。

于 2013-05-15T15:14:12.623 回答