S-T
S-T

Reputation: 489

Uninstall Django completely

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 ?

Upvotes: 22

Views: 172922

Answers (12)

Poddar Bhardwaj
Poddar Bhardwaj

Reputation: 11

pip uninstall django

or

python -m pip uninstall django

will easily uninstall django

Upvotes: 1

aman Kumar mahore
aman Kumar mahore

Reputation: 53

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.

Upvotes: 4

hassan hassairi
hassan hassairi

Reputation: 71

open the CMD and use this command :

**

pip uninstall django

**

it will easy uninstalled .

Upvotes: 7

Anurag Sinha
Anurag Sinha

Reputation: 197

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.

Upvotes: 0

The_Coder
The_Coder

Reputation: 321

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.

Upvotes: 0

David Karla
David Karla

Reputation: 89

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.

Upvotes: 0

Jon
Jon

Reputation: 1180

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.

Upvotes: 0

Yang Wang
Yang Wang

Reputation: 600

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)"

Upvotes: 0

hiallen
hiallen

Reputation: 29

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

Upvotes: -1

S-T
S-T

Reputation: 489

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.

Upvotes: 6

mitnk
mitnk

Reputation: 3307

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/

Upvotes: 5

falsetru
falsetru

Reputation: 369064

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

Upvotes: 18

Related Questions