Virtualenv正在尝试安装在系统目录中

时间:2013-05-15 03:53:22

标签: python macos virtualenv

我之前遇到了一个问题,试图在我的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

1 个答案:

答案 0 :(得分: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?我不确定它究竟是做什么的,但是looking at the install file它会改变你的shell的启动命令,这可能会导致你的问题。

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

mv ~/.venvburrito ~/.venvburrito.disabled

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

rm -fr ~/.venvburrito.disabled

它还会在其中一个文件中安装一些代码(取决于你的shell):

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

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