Python 完全卸载 Django
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20897851/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uninstall Django completely
提问by S-T
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.
我使用pip uninstall Django. 它说已成功卸载,而当我在 python shell 中看到 django 版本时,它仍然提供我安装的旧版本。
To remove it from python path, I deleted the djangofolder under /usr/local/lib/python-2.7/dist-packages/.
若要从Python路径中删除它,我删除了django文件夹下/usr/local/lib/python-2.7/dist-packages/。
However sudo pip search Django | more /^Djangocommand still shows Djangoinstalled version. How do i completely remove it ?
但是sudo pip search Django | more /^Django命令仍然显示Django已安装的版本。我如何完全删除它?
回答by falsetru
pip searchcommand does not show installed packages, but search packages in pypi.
pip search命令不显示已安装的包,而是在 pypi 中搜索包。
Use pip freezecommand and grepto see installed packages:
使用pip freeze命令和grep查看已安装的软件包:
pip freeze | grep Django
回答by mitnk
Use Python shell to find out the path of Django:
使用 Python shell 找出 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/
回答by S-T
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)
解决了。我错过了删除所有以前 Django 版本的 egg_info 文件。将它们从/usr/local/lib/python2.7/dist-packages. 也来自/usr/lib/python2.7/dist-packages(如果这里有的话)
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.
以上所有命令都不应显示 Django 版本来验证 clean uninstallation。
回答by hiallen
If installed Django using python setup.py install
如果使用 python setup.py install 安装了 Django
python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)"
find the directory you need to remove, delete it
找到需要删除的目录,删除
回答by Yang Wang
Remove any old versions of Django
删除所有旧版本的 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.
如果您要从以前的版本升级 Django 的安装,则需要在安装新版本之前卸载旧的 Django 版本。
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.
如果您之前使用 pip 或 easy_install 安装 Django,再次使用 pip 或 easy_install 安装将自动处理旧版本,因此您无需自己动手。
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 setup.py install 安装了 Django,卸载就像从 Python 站点包中删除 django 目录一样简单。要查找需要删除的目录,您可以在 shell 提示符(不是交互式 Python 提示符)下运行以下命令:
$ python -c "import django; print(django.path)"
$蟒蛇-c “进口Django的;打印(Django的路径)”
回答by Jon
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)
我不得不使用 pip3 而不是 pip 以获得正确版本的python(python 3.4而不是python 2.x)的正确版本
Check what you got install at: /usr/local/lib/python3.4/dist-packages
检查您安装的内容:/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.
此外,当您运行 python 时,您可能必须编写 python3.4 而不是 python 才能使用正确版本的 python。
回答by David Karla
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.
在 Windows 上,由于在 cygwin 下安装了 django (1.8.7) 实例,我在使用 python 2.7 的 pydev/eclipse 下出现静态文件时遇到了这个问题。这导致了 windows 样式路径和 cygwin 样式路径之间的冲突。因此,尽管进行了上述所有修复,但仍无法找到静态文件。我删除了额外的发行版(以便所有软件包都在 windows 下通过 pip 安装),这解决了问题。
回答by The_Coder
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.
我在 pip uninstall 命令之后使用了@ST 提到的相同方法。甚至在那之后,我收到了 Django 已经安装的消息。所以我从“/usr/lib/python2.7/dist-packages”中删除了“Django-1.7.6.egg-info”文件夹,然后它对我有用。
回答by Anurag Sinha
The Issue is with pip --version or python --version.
问题在于 pip --version 或 python --version。
try solving issue with pip2.7 uninstall Djangocommand
尝试用pip2.7 uninstall Django命令解决问题
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:
如果您无法使用上述命令卸载,那么请确保您的 pip2.7 版本未安装,因此您可以按照以下步骤操作:
1)which pip2.7it should give you an output like this :
1)which pip2.7它应该给你一个这样的输出:
/usr/local/bin/pip2.7
2) If you have not got this output please install pip using following commands
2) 如果你没有得到这个输出,请使用以下命令安装 pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python2.7 get-pip.py
3) Now check your pip version : which pip2.7Now you will get
3) 现在检查你的 pip 版本:which pip2.7现在你会得到
/usr/local/bin/pip2.7 as output
4) uninstall Django using pip2.7 uninstall Djangocommand.
4) 使用pip2.7 uninstall Django命令卸载 Django 。
Problem can also be related to Python version. I had a similar problem, this is how I uninstalled Django.
问题也可能与 Python 版本有关。我遇到了类似的问题,这就是我卸载 Django 的方式。
Issue occurred because I had multiple python installed in my virtual environment.
出现问题是因为我在我的虚拟环境中安装了多个 python。
$ 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 DjangoDjango got uninstalled from python 2.7 but not from python 3.4 so I followed the following steps to resolve the issue :
现在,当我尝试使用pip uninstall DjangoDjango 卸载时,从 python 2.7 卸载了,但没有从 python 3.4 卸载,所以我按照以下步骤解决了这个问题:
1)alias python=/usr/bin/python3
1)alias python=/usr/bin/python3
2) Now check your python version using python -Vcommand
2)现在使用python -V命令检查您的python版本
3) If you have switched to your required python version now you can simply uninstall Django using pip3 uninstall Djangocommand
3) 如果你现在已经切换到你需要的 python 版本,你可以简单地使用pip3 uninstall Django命令卸载 Django
Hope this answer helps.
希望这个答案有帮助。
回答by hassan hassairi
open the CMD and use this command :
打开 CMD 并使用以下命令:
**
**
pip uninstall django
pip卸载django
**
**
it will easy uninstalled .
它会很容易卸载。

