所以我正在尝试使用pip下载请求,我收到以下错误。我已经检查了错误日志,但这对我来说很难理解。
有什么建议吗?当我尝试使用pip for beautifulsoup4时,我遇到了类似的问题。
~ ∴ pip install requests
Downloading/unpacking requests
Downloading requests-2.2.1-py2.py3-none-any.whl (625kB): 625kB downloaded
Installing collected packages: requests
Cleaning up...
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.5.2-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.2-py2.7.egg/pip/commands/install.py", line 279, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py", line 1380, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py", line 664, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py", line 894, in move_wheel_files
pycompile=self.pycompile,
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/wheel.py", line 202, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/wheel.py", line 189, in clobber
os.makedirs(destsubdir)
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/requests'
Storing debug log for failure in /Users/my_name/Library/Logs/pip.log
答案 0 :(得分:15)
您正尝试在'/Library/Python/2.7/site-packages/requests'中安装该软件包,但它需要root权限才能执行此操作。这应该可以解决问题:
$ sudo pip install requests
答案 1 :(得分:9)
试试这个:
pip install --user requests
(就像它写的那样,你不必替换任何东西)
答案 2 :(得分:3)
这是重要的部分:
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/requests'
要在系统范围内安装库(在该文件夹中),您需要root权限,请使用sudo:
sudo pip install requests
或者,请查看virtualenv,以便您可以在不需要root的情况下进行不同的本地安装。
答案 3 :(得分:2)
对于Mac OS X:
首先通过此命令安装pip:
sudo easy_install pip
然后通过此命令安装请求:
pip install --user requests
答案 4 :(得分:0)
如果您在Pycharm中,尝试将请求从2.5更新到2.7,您将得到相同的错误,我在命令行中输入以下内容:
sudo pip install --upgrade requests
如果要求输入密码,只需输入计算机密码
它对我有用
答案 5 :(得分:0)
表示ubuntu
sudo apt-get install python-requests
全部完成!!