在python 3.5.1 mac上安装模块'requests'

时间:2016-03-14 08:12:23

标签: python python-3.x

我是python的新手,最近安装了python 3.5.1,我试图通过在终端中编写以下内容来安装模块'requests':

pip install requests

但是我收到以下错误。非常感谢您提供的任何帮助!

Collecting requests  
  Using cached requests-2.9.1-py2.py3-none-any.whl  
Installing collected packages: requests  
Exception:  
Traceback (most recent call last):  
  File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/basecommand.py", line 209, in main  
    status = self.run(options, args)  
  File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/commands/install.py", line 317, in run  
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/req/req_set.py", line 732, in install  
    **kwargs  
  File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/req/req_install.py", line 835, in install  
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)  
  File "/Library/Python/2.7/site-packages/pip-8.1.0-  py2.7.egg/pip/req/req_install.py", line 1030, in move_wheel_files  
    isolated=self.isolated,  
  File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/wheel.py", line 344, in move_wheel_files  
    clobber(source, lib_dir, True)  
  File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/wheel.py", line 315, in clobber  
    ensure_dir(destdir)  
  File "/Library/Python/2.7/site-packages/pip-8.1.0-  py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir  
    os.makedirs(path)  
  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'  

1 个答案:

答案 0 :(得分:2)

您尝试将requests安装到您无权执行此操作的地方。

如果你sudo,即。 sudo pip install requests它会成功。此外,您可以查看虚拟环境以在本地管理依赖性。

此外,由于使用requests Python 2.7.xpip,您正在安装{2.7}版本的pip。如果您要安装的话,那么您需要明确使用pip3.5 for 3.5。将有public class PageAdapter extends FragmentStatePagerAdapter { int mNumOfTabs; public PageAdapter(FragmentManager fm, int NumOfTabs) { super(fm); this.mNumOfTabs = NumOfTabs; } @Override public Fragment getItem(int position) { switch (position) { case 0: AllTasksTabFragment tab1 = new AllTasksTabFragment(); return tab1; case 1: WaitingTasksTabFragment tab2 = new WaitingTasksTabFragment(); return tab2; default: return null; } } @Override public int getCount() { return mNumOfTabs; } 二进制文件,或者您可以使用pip for Python 3.5.x的完整路径启动它。