Uninstall Django completely

前端 未结 10 2175
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 10:01

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 give

相关标签:
10条回答
  • 2020-12-24 10:06

    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/
    
    0 讨论(0)
  • 2020-12-24 10:07

    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.

    0 讨论(0)
  • 2020-12-24 10:08

    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

    0 讨论(0)
  • 2020-12-24 10:16

    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.

    0 讨论(0)
  • 2020-12-24 10:16

    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.

    0 讨论(0)
  • 2020-12-24 10:17

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

    0 讨论(0)
提交回复
热议问题