我使用sudo easy_install pip
安装了pip,这样我就可以为python加载boto了。然后我做了pip install -U boto
并发生了这个错误
Installing collected packages: boto
Cleaning up...
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 671, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 901, in move_wheel_files
pycompile=self.pycompile,
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/wheel.py", line 215, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/wheel.py", line 205, in clobber
os.makedirs(destdir)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/boto'
Storing debug log for failure in /Users/DRizzuto/Library/Logs/pip.log
然后我尝试了easy_install boto
并发现此错误
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-2024.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.
我现在不知道如何安装boto。有人可以解释我如何绕过或摆脱这些错误吗?
答案 0 :(得分:5)
您需要以root身份运行pip命令。 (或等效即sudo)
基于Mac的示例
sudo pip install -U boto
答案 1 :(得分:1)
默认情况下,pip尝试在/Library/Python/2.7/site-packages/
中安装软件包,如错误消息中所示。该目录属于“root”用户,普通帐户无权在那里安装。
sudo
以root身份运行命令,因此在这种情况下,您只需输入
sudo pip install -U boto
答案 2 :(得分:0)
如果 boto ,您不需要使用sudo
。
使用sudo
(将模块安装到全局路径)对于真正属于全局路径的模块来说可能是一个很好的解决方案(这意味着我们确信我们将在整个系统中使用这些模块 - 通常是{{}等工具1}},ansible
,也许virtualenv
- 但这是有争议的。)
大多数其他依赖项(包括fabric
)应始终在boto
中定义,应与应用程序一起打包。每个应用程序可能(并且将)具有不同的依赖关系,不同版本的不同模块以及不希望在全局路径中引起任何冲突/混乱。
但是使用requirements.txt
,您可以创建一个虚拟环境,并且只保留全局环境中最重要的内容(如实际的virtualenv
模块)以及“虚拟”中所有与项目相关的依赖项环境。
详细了解virtualenv
:http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/
除了virtualenv
之外,可能还有更多其他解决方案可用于隔离环境,
但重点是你应该隔离它。
答案 3 :(得分:0)