1

Am getting a "Permission denied" error pertaining to a file named DESCRIPTION.rst while trying to PIP uninstall a package in order to upgrade it.

I originally ran this command:

pip uninstall twilio

There was a lot of output, but the important stuff was:

...
...
  /usr/local/lib/python2.7/site-packages/twilio/version.pyc
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/commands/uninstall.py", line 59, in run
    requirement_set.uninstall(auto_confirm=options.yes)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1035, in uninstall
    req.uninstall(auto_confirm=auto_confirm)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 598, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1836, in remove
    renames(path, new_path)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 295, in renames
    shutil.move(old, new)
  File "/usr/local/lib/python2.7/shutil.py", line 303, in move
    os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/twilio-3.6.6.dist-info/DESCRIPTION.rst'

Storing debug log for failure in /home/chris/.pip/pip.log
[chris@boogie-dev ~]$ 

I'm not really sure how I should go about solving this problem. I don't understand PIP too well, or the ins and outs of python library pakcages, or what a DESCRIPTION.rst file is and why it is there with special permissions.

I already tried the command under sudo, however PIP is not available under sudo. I'm not sure what is the correct angle to take on this problem:

  • Install pip under the sudo account and then try to uninstall using the sudo account - which is not the same account that was using to originally install the package
  • Delete the DESCRIPTION.rst file while using sudo
  • Some other, more elegant approach that I'm not aware of
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258

2 Answers2

1

Instead of downloading modules from python.org you can download modules using pip, but while doing this you should be in root mode.

First when you are running

root@achal-PC:~# apt-get install python-pip
...it will install pip tool...

root@achal-PC:~# which pip
/usr/bin/pip

next when you are installing twilio as

root@achal-PC:~# pip install twilio
..Successfully installed twilio PyJWT pytz...

Instead of un-install do upgrade there itself as

root@achal-PC:~# pip install --upgrade twilio
Requirement already up-to-date: twilio in /usr/local/lib/python2.7/dist-packages
Cleaning up..

I hope it helps.

Achal
  • 11,821
  • 2
  • 15
  • 37
-3

I had the same problem. Try with --user flag, like this: pip uninstall --user twilio.

While in my case it didn't change the location of where my package was installed / uninstalled, my guess is that it avoids touching some files that are reserved for root access. More info in this question: What is the purpose "pip install --user ..."?

kewkie
  • 1