21

I uninstalled django on my machine using pip uninstall Django. It says successfully uninstalled whereas when I see django version in python shell, it still gives the older version I installed.

To remove it from python path, I deleted the django folder under /usr/local/lib/python-2.7/dist-packages/.

However sudo pip search Django | more /^Django command still shows Django installed version. How do i completely remove it ?

falsetru
  • 357,413
  • 63
  • 732
  • 636
S-T
  • 479
  • 2
  • 4
  • 17

11 Answers11

18

pip search command does not show installed packages, but search packages in pypi.

Use pip freeze command and grep to see installed packages:

pip freeze | grep Django
falsetru
  • 357,413
  • 63
  • 732
  • 636
  • pip freeze | grep Django says Django==1.5. How do i uninstall it? – S-T Jan 03 '14 at 06:37
  • I did it just now again. It says successfully uninstalled. pip freeze still has the same result. – S-T Jan 03 '14 at 06:40
  • @S-T, What is the output of `pip show Django` and `pip show -f Django`? – falsetru Jan 03 '14 at 06:47
  • pip show Django output: Name: Django Version: 1.5 Location: /usr/local/lib/python2.7/dist-packages – S-T Jan 03 '14 at 07:20
  • @S-T, Is `/usr/local/lib/python2.7/dist-packages/django` still there? – falsetru Jan 03 '14 at 07:22
  • No it isn't there. Not any folder I can see. This is really absurd or I am doing something horribly wrong – S-T Jan 03 '14 at 07:33
  • 1
    @S-T, What is the output of `which pip`. Maybe you're using pip that reference another version of python .. ? – falsetru Jan 03 '14 at 07:34
  • pip show -f Django output: Name: Django Version: 1.5 Location: /usr/local/lib/python2.7/dist-packages Requires: Files: ../django/__init__.py – S-T Jan 03 '14 at 07:35
  • Oh k, `which pip` says : `/usr/local/bin/pip` and not `/usr/local/bin/pip2.7` – S-T Jan 03 '14 at 07:37
6

Got it solved. I missed to delete the egg_info files of all previous Django versions. Removed them from /usr/local/lib/python2.7/dist-packages. Also from /usr/lib/python2.7/dist-packages (if any present here)

sudo pip freeze| grep Django
sudo pip show -f Django
sudo pip search Django | more +/^Django

All above commands should not show Django version to verify clean uninstallation.

S-T
  • 479
  • 2
  • 4
  • 17
6

open the CMD and use this command :

**

pip uninstall django

**

it will easy uninstalled .

5

Use Python shell to find out the path of Django:

>>> import django
>>> django
<module 'django' from '/usr/local/lib/python2.7/dist-packages/django/__init__.pyc'>

Then remove it manually:

sudo rm -rf /usr/local/lib/python2.7/dist-packages/django/
mitnk
  • 3,127
  • 2
  • 21
  • 28
3

first use the command

pip uninstall django

then go to python/site-packages and from there delete the folders for django and its site packages, then install django. This worked for me.

Florian Winter
  • 4,750
  • 1
  • 44
  • 69
0

Remove any old versions of Django

If you are upgrading your installation of Django from a previous version, you will need to uninstall the old Django version before installing the new version.

If you installed Django using pip or easy_install previously, installing with pip or easy_install again will automatically take care of the old version, so you don’t need to do it yourself.

If you previously installed Django using python setup.py install, uninstalling is as simple as deleting the django directory from your Python site-packages. To find the directory you need to remove, you can run the following at your shell prompt (not the interactive Python prompt):

$ python -c "import django; print(django.path)"

Yang Wang
  • 580
  • 4
  • 14
0

I had to use pip3 instead of pip in order to get the right versions for the right version of python (python 3.4 instead of python 2.x)

Check what you got install at: /usr/local/lib/python3.4/dist-packages

Also, when you run python, you might have to write python3.4 instead of python in order to use the right version of python.

Jon
  • 1,060
  • 8
  • 15
0

On Windows, I had this issue with static files cropping up under pydev/eclipse with python 2.7, due to an instance of django (1.8.7) that had been installed under cygwin. This caused a conflict between windows style paths and cygwin style paths. So, unfindable static files despite all the above fixes. I removed the extra distribution (so that all packages were installed by pip under windows) and this fixed the issue.

David Karla
  • 89
  • 1
  • 3
0

I used the same method mentioned by @S-T after the pip uninstall command. And even after that the I got the message that Django was already installed. So i deleted the 'Django-1.7.6.egg-info' folder from '/usr/lib/python2.7/dist-packages' and then it worked for me.

The_Coder
  • 321
  • 5
  • 18
0

The Issue is with pip --version or python --version.

try solving issue with pip2.7 uninstall Django command

If you are not able to uninstall using the above command then for sure your pip2.7 version is not installed so you can follow the below steps:

1)which pip2.7 it should give you an output like this :

/usr/local/bin/pip2.7

2) If you have not got this output please install pip using following commands

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python2.7 get-pip.py

3) Now check your pip version : which pip2.7 Now you will get

/usr/local/bin/pip2.7 as output 

4) uninstall Django using pip2.7 uninstall Django command.

Problem can also be related to Python version. I had a similar problem, this is how I uninstalled Django.

Issue occurred because I had multiple python installed in my virtual environment.

$ ls

activate       activate_this.py  easy_install-3.4  pip2.7  python     python3        wheel
activate.csh   easy_install      pip               pip3    python2    python3.4
activate.fish  easy_install-2.7  pip2              pip3.4  python2.7  python-config

Now when I tried to un-install using pip uninstall Django Django got uninstalled from python 2.7 but not from python 3.4 so I followed the following steps to resolve the issue :

1)alias python=/usr/bin/python3

2) Now check your python version using python -V command

3) If you have switched to your required python version now you can simply uninstall Django using pip3 uninstall Django command

Hope this answer helps.

Anurag Sinha
  • 187
  • 4
  • 15
-1

If installed Django using python setup.py install

python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)"

find the directory you need to remove, delete it

hiallen
  • 29
  • 2