Python:安装pip时出现拒绝权限错误

2024-10-01 09:29:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我是一名学生,我在系计算机系统Linux7.2上做项目。现在我正在尝试安装pip,以便可以使用它安装python包。在

我已经下载了get-pip.py,并试图通过python get-pip.py进行安装。它给了我:

Collecting pip
Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
 100% |████████████████████████████████| 1.2MB 471kB/s 
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
 100% |████████████████████████████████| 71kB 764kB/s 
Installing collected packages: pip, wheel
Exception:
 Traceback (most recent call last):
 File "/tmp/tmpqybTwL/pip.zip/pip/basecommand.py", line 209, in main
   status = self.run(options, args)
 File "/tmp/tmpqybTwL/pip.zip/pip/commands/install.py", line 317, in run
   prefix=options.prefix_path,
 File "/tmp/tmpqybTwL/pip.zip/pip/req/req_set.py", line 732, in install
   **kwargs
 File "/tmp/tmpqybTwL/pip.zip/pip/req/req_install.py", line 835, in   install
   self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
 File "/tmp/tmpqybTwL/pip.zip/pip/req/req_install.py", line 1030, in move_wheel_files
   isolated=self.isolated,
 File "/tmp/tmpqybTwL/pip.zip/pip/wheel.py", line 344, in move_wheel_files
   clobber(source, lib_dir, True)
 File "/tmp/tmpqybTwL/pip.zip/pip/wheel.py", line 315, in clobber
   ensure_dir(destdir)
 File "/tmp/tmpqybTwL/pip.zip/pip/utils/__init__.py", line 83, in ensure_dir
   os.makedirs(path)
 File "/usr/lib64/python2.7/os.py", line 157, in makedirs
   mkdir(name, mode)

OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/pip'

然后,我试图使用sudo python get-pip.py安装,但是,我得到了"xxx is not in the sudoers file. This incident will be reported."

所以,我想知道我是不是没有权限扎根,也没有权利做sudo…但我不确定。。。在

有什么解决这个问题的建议吗?最后,我想安装scipy和{}。在


Tags: installpipinpyselfgetprefixdir
3条回答

您要么需要使用虚拟环境,然后在虚拟环境中安装pip包。或者以root用户的身份在全局ie系统范围内使用pip进行安装

系统是否会给您一个virtualenv命令?在

不管怎样,Then you should read about virtualenvs.还是很有用的。在

如果没有,您可以使用the approach by Jasper van den Bosch

尝试使用easy_install安装pip 在终端尝试以下命令:

 sudo su
 easy_install pip

相关问题 更多 >