Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
768 views
in Technique[技术] by (71.8m points)

shell - pip is not uninstalling packages

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...