Python: permission denied error when installing pi

2019-07-19 08:04发布

问题:

I am a student and I am doing project on department computer, system Linux 7.2. Now I am trying to install pip so that I can install python packages using it.

I have downloaded get-pip.py and tried to install via python get-pip.py. It gives me:

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'

Then, I tried to install using sudo python get-pip.py, however, I got "xxx is not in the sudoers file. This incident will be reported."

So, I was wondering whether I don't have the permission to root and don't have the right to do sudo...but I am not sure about this...

Any suggestion to fix this problem? And in the end, I want to install scipy and gensim.

回答1:

Does the system hand you a virtualenv command?

Then you should read about virtualenvs. Comes in handy anyhow.

If not you may use the approach by Jasper van den Bosch



回答2:

You either need to use a virtual environement, and install the pip package in the virtual env. Or install it with pip globally ie system wide as root user



回答3:

Try install pip using easy_install Try Below commands in terminal:

 sudo su
 easy_install pip