gpt4 book ai didi

python - 无法在 OSX 上运行 virtualenv?

转载 作者:行者123 更新时间:2023-11-28 19:57:42 26 4
gpt4 key购买 nike

sudo virtualenv foo

New python executable in foo/bin/python
Installing setuptools.............done.
Installing pip....
Complete output from command /private/tmp/foo/bin/python -x /private/tmp/foo/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz:
/private/tmp/foo/bin/python: can't open file '/private/tmp/foo/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.8.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 1054, 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 655, in install_pip
filter_stdout=_filter_setup)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1020, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /private/tmp/foo/bin/python -x /private/tmp/foo/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz failed with error code 2

虚拟环境 foo

New python executable in foo/bin/python
Installing setuptools.............................
Complete output from command /private/tmp/foo/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-1712.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.8.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 599, in install_setuptools
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 571, 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 /private/tmp/foo/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])






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

我正在运行 Python 2.7.3,除了 OSX Mountain Lion 上默认安装的 pip 和 virtualenv 之外,没有安装任何包。

最佳答案

您的 Python 安装有问题。

首先,运行 sudo virtualenv foo 没有任何意义。 virtualenv 的全部意义在于,您永远不需要 root 访问权限来安装软件包。你将永远需要 sudo 来使用 virtualenv。

其次,/Library/Python/2.7/site-packages/virtualenv.py 默认不包含在 Mountain Lion 中。有些东西在那里安装了它,所以当你说“除了默认安装的包之外没有安装任何包”时,你是错误的。根据您的安装方式,它可能安装错误。

看起来即使您正在创建一个 virtualenv,它也在尝试将包安装到 /Library/Python/2.7/site-packages/,这应该是不可能的。会不会是你用sudo easy_install安装virtualenv,或者手动把一些package放在/Library/Python/2.7/site-packages/

我会建议撤消和卸载你安装的任何东西,让你的系统恢复到标准的 Mac OS X 设置,然后使用 virtualenv-burrito 代替,它是一个一步命令,将安装 virtualenv 和无需思考即可为您 pip :https://github.com/brainsik/virtualenv-burrito

关于python - 无法在 OSX 上运行 virtualenv?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13336665/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com