pip is not uninstalling packages - shell

Background
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) python-twitter0.8.2 (http://pypi.python.org/pypi/python-twitter/0.8.2)
b) twitter1.9.1 (http://pypi.python.org/pypi/twitter/1.9.1)
(a) is called python-twitter in pypi, and (b) is called twitter, so that's how I'll refer to them.
Both of these are called by import twitter in the Python interpreter, but when I write that line, I always get the twitter one (if I can figure out how to use the python-twitter one, I'll be able to proceed, but will still have the same underlying problem).
Problem
Since I don't need the twitter package, I decided to uninstall it with pip:
$ sudo pip uninstall twitter
which gives the output:
Uninstalling twitter:
Proceed (y/n)? y
Successfully uninstalled twitter
(actually, I tried the same thing with python-twitter and got a similar response).
However, when running pip freeze, both of these packages show up on the installed list! In fact, I can still use the import twitter command successfully in the interpreter. Clearly the packages have not been uninstalled. What I would love to know is how to uninstall them!
Other Info
I'm using Python 2.7 and Ubuntu 12.04
When running IDLE instead of the shell interpreter, and I type help('modules'), neither twitter nor python-twitter shows up in the list. When typing help('modules') into the shell interpreter, I get a segmentation fault error, and the interpreter crashes. Here's the error:
>>> help('modules')
Please wait a moment while I gather a list of all available modules...
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
from gtk import _gtk
** (python:2484): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register
existing type `GdkDevice'
from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata:
assertion `node != NULL' failed
from gtk import _gtk
Segmentation fault (core dumped)
Why other questions have not resolved this for me:
I looked at the similar post at pip freeze lists uninstalled packages and am not having the same issues.
$ sudo which pip
/usr/bin/pip
$ which pip
/usr/bin/pip
which is the same output. In addition, $ sudo pip freeze gives the same output as $ pip freeze.
Any help is very much appreciated!

You can always manually delete the packages; you can run:
sudo rm -rf /usr/local/lib/python2.7/dist-packages/twitter
to remove that package from your dist-packages directory. You may have to edit the easy-install.pth file in the same directory and remove the twitter entry from it.

While Martin's solution works, as a work around, it does not provide a direct answer.
Ubuntu's pip version for your Ubuntu version (12.04) is:
python-pip (1.0-1build1)
This is also the same version for Debian Wheezy. This version has a weired bug, which causes packages not to be removed.
If you obtain pip from upstream using the script get-pip.py you will have a fixed version of pip which can remove pacakges (as of now v. 1.5.6).
update
Python's pip is really a fast moving target. So using Debian's or Ubuntu's pip is guaranteed to have bugs. Please don't use those distribution's pip.
Instead install pip from upstream.
If you would like to register pip installed packages as system packages I really recommend that you also use stdeb.

I was facing difficulty while upgrading a package because pip was not able to uninstall it successfully. I had to delete the .egg-info and the folder as well in /usr/lib/python2.7/dist-packages and then I tried to install with --upgrade and it worked.

For me, it was due to the fact that I was running pip freeze, which gave me different results than sudo pip freeze.
Since I was uninstalling using sudo, it was not uninstalling it in the "non-sudo" session. Uninstalling without sudo fixed that.

In my case (moving pyusb 0.4x to 1.0x), removing the old package with apt-get remove python-usb and manually installing the manually downloaded package via python setup.py worked. Not pretty, but working.

Related

pip install psd-tools3 => FileNotFoundError: [Errno 2] No such file or directory

I was trying to install Ursina but I was having trouble getting all the required packages I needed to run my code properly. Come to find out, there's a package that refuses to install called 'psd-tools3' that won't install, no matter what I do.
I've been using cmd commands like 'pip install psd-tools3' and 'pip3 install psd-tools3' but no other commands work (i.e. 'sudo pip install psd-tools3' doesn't work because my PC doesn't know what 'sudo' means and doesn't run). I've tried installing required packages for this package, but nothing works. It just keeps giving me this error:
enter image description here
I would really appreciate the help with this problem. All I can really assume is that the Python file '_version' hasn't been created and that's what's throwing the whole program off. If there is a way to add this manually and then install it, I would appreciate steps to do that as well.
I was running this on a Lenovo Thinkpad (Windows 10) on Python 3.10 (I also have Python 3.8.3 but that was installed with the 3.10) and I made sure all packages and pip are up-to-date. Still having this problem and I don't know why.
Seems to me like the issue is on the side of the maintainers of psd-tools3.
For example, looking at the content of the latest source distribution on PyPI, we can see that it does not contain any _version.py file.
This needs to be solved by the project's maintainers, but they do not have a ticket tracker. On the other hand there seems to be an "Author" email address on the project's PyPI page as well as in the project's setup.py script.
A solution might be to clone the project's source code repository (with git), and try to install from the local clone.
Just simply try
pip install psd-tools3==1.9.0
Or
pip install psd-tools3==1.8.2
This should work on your pc as well. I was having same issue, and then I tried this It worked for me

Environment error when installing with pip

I'm trying to install some python libraries with pip and I'm getting a repeated error when running it. For example, if I run pip install -U py2app the download appears to proceed as normally, but then an error is raised:
Could not install packages due to an EnviromentError
Which is followed by a series of [Errno 1] Operation not permitted errors (with directories listed after each error).
This error has appeared a number of times on several different libraries I've attempted to install, and it's extremely frustrating. I've tried to update the tools that people have recommended to update for various pip errors and none of them have made any difference.
Is there an easy fix to this problem?
Try to install using the option --user for example:
$ pip install --user py2app
Passing the --user option will install a package just for the current user, rather than for all users of the system.

Python 3.5.1 pip install 'ImportError'

While using pip install I am getting the following error:
Error while finding spec for 'pip__main__' <: No module named 'urllib.request'; 'urllib' is not a package>; 'pip' is a package and cannot be directly executed
Any advice on this one?
I thought maybe it was related to the requests module itself but I tried to download other modules and had the same problem.
I've just upgraded from Python 3.3 to v3.5.1 on Windows and hit the same error message. I understand it's not the same as your problem.
It seems that the instructions from the docs to use:
python -m pip install SomePackage
are wrong, at least for Windows because I get the error message quoted by the OP.
I forgot to add the Scripts directory to my path, the same as previous releases. When I add it the problem is fixed. My path now has (for a default install of Python 3.5):
PATH=<blah>;%USERPROFILE%\AppData\Local\Programs\Python\Python35;%USERPROFILE%\AppData\Local\Programs\Python\Python35\Scripts
The pip executable is located in Scripts, so pip commands can now be executed directly, the same as always:
pip install urllib

python3-pip installed but pip3 command not found?

I am testing a Python3 program in several computers. To do that, I need to install a library of Python with pip3.
So first, I was installing python3-pip in each computer (everyone is running a Kubuntu OS). Everything was OK, and then I installed the package I needed with pip3, and I managed to do that except for one computer.
In that computer, python3-pip was apparently installed succesfully, but when I look for the package, I get this error (the translation is homemade):
Command «pip3» was not found, may be you wanted to say:
The command «pip» from the package «python-pip» (universe)
pip3: command not found
By the way, I had asked this question here https://superuser.com/questions/769920/python3-pip-installed-but-pip3-command-not-found too. There is an answer which has several votes, in my case, may be I was doing something wrong but it not worked. But try it, may be you are luckier than me!

PIP uninstall shows package uninstalled, but actually it is not

I am trying to remove and install again a package, 'python-keystoneclient' using pip. The problem is, when I run pip uninstall python-keystoneclient, it is showing successfully uninstalled:
root#openstack1:~/cinder# pip uninstall python-keystoneclient
Uninstalling python-keystoneclient:
Proceed (y/n)? y
Successfully uninstalled python-keystoneclient
but when I do a pip search python-keystoneclient, it shows:
root#openstack1:~/cinder# pip search python-keystoneclient
python-keystoneclient - Client library for OpenStack Identity API
(Keystone)
INSTALLED: 0.2.1 (latest)
I have tried installing the package again, but it shows requirement already satisfied. Not sure why this is happening.
Chances are it's installed somewhere else via a package or mechanism that PIP isn't entirely aware of. Plus last I heard, pip uninstall worked in the simple cases, but it was easy to fool and not entirely consistent on all platforms.
I've resorted to doing something like
python -c "import sys;import pprint;pprint.pprint(sys.path)"
to show me where python is potentially finding it's modules - that will show you if you've done something like left a local directory somewhere in the system path for python (happens to me after doing a "python setup.py develop" from a directory when I'm root and not paying attention).
You can also just ask keystoneclient where it's been imported from with a similar setup, which you can use to find and nuke it:
python -c "import keystoneclient;print keystoneclient.__file__"
You have to manually uninstall the keystone-client.
On my server, under
/usr/local/lib/python2.7/dist-packages/python_keystoneclient-0.3.2-py2.7.egg-info (you may have a different version number on your server)
you can find a installed-files.txt file, which records all the files installed by keystone-client.
Then, delete them and the related directories in dist-packages.
cat installed-files.txt | xargs sudo rm -rf
cd ..
sudo rm -rf keystoneclient python_keystoneclient-0.3.2-py2.7.egg-info
Now, keystoneclient has been fully uninstalled.

Resources