Python 如何升级django?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23708895/
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
How to upgrade django?
提问by user3030969
My project was running on Django 1.5.4 and I wanted to upgrade it. I did pip install -U -I django
and now pip freeze
shows Django 1.6.5 (clearly django has upgraded, I'm in virtualenv
) but my project is still using Django 1.5.4. How can I use the upgraded version?
我的项目在 Django 1.5.4 上运行,我想升级它。我做了pip install -U -I django
,现在pip freeze
显示 Django 1.6.5(显然 django 已经升级,我在virtualenv
)但我的项目仍在使用 Django 1.5.4。如何使用升级版?
UPDATE: Thanks for your comments. I tried everything but unfortunately nothing worked and I had to re-deploy the app.
更新:感谢您的评论。我尝试了一切,但不幸的是没有任何效果,我不得不重新部署该应用程序。
Hope someone explains why this happened.
希望有人解释为什么会发生这种情况。
回答by Yogesh dwivedi Geitpl
You can use --upgrade
with the pip
command to upgrade Python packages.
您可以使用--upgrade
该pip
命令来升级 Python 包。
pip install --upgrade django==1.6.5
回答by ruddra
I use this command for upgrading any package using pip:
我使用此命令使用 pip 升级任何包:
pip install <package-name> --upgrade
Example: pip install django --upgrade
例子: pip install django --upgrade
you need to use the --upgrade
or -U
flag for upgrading.
您需要使用--upgrade
或-U
标志进行升级。
Alternatively, you can use python -m pip install -U Django
.
或者,您可以使用python -m pip install -U Django
.
回答by guettli
You can use the upgraded version after upgrading.
升级后可以使用升级后的版本。
You should check that all your tests pass before deploying :-)
您应该在部署之前检查所有测试是否通过:-)
回答by GrvTyagi
- Use this command to get all available Django versions:
yolk -V django
- Type
pip install -U Django
for latest version, or if you want to specify version then usepip install --upgrade django==1.6.5
- 使用此命令获取所有可用的 Django 版本:
yolk -V django
- 键入
pip install -U Django
的最新版本,或者如果你想指定的版本,则使用pip install --upgrade django==1.6.5
NOTE:Make sure you test locally with the updated version of Django before updating production.
注意:请确保在更新生产之前使用更新版本的 Django 进行本地测试。
回答by MD Shahrouq
sudo pip install --upgrade django
sudo pip install --upgrade django
also upgrade the DjangoRestFramework:
还要升级 DjangoRestFramework:
sudo pip install --upgrade djangorestframework
sudo pip install --upgrade djangorestframework
回答by Sam Vyatkin
You can use pip install -U django. It will update to the current stable version. Read official documentation on Django Docs
您可以使用pip install -U django。它将更新到当前的稳定版本。阅读有关Django Docs 的官方文档
回答by mike rodent
I'm not an expert on either Python or Django.
我不是 Python 或 Django 的专家。
What I am doing is following along this really very good book: Test Driven Web Development With Python (2nd Ed). It uses Django...
我正在做的是遵循这本非常好的书:使用 Python 进行测试驱动的 Web 开发(第 2 版)。它使用 Django...
I'm also using a Windoze machine (W10) with Cygwin.
我还使用带有 Cygwin 的 Windoze 机器 (W10)。
The reason I mention all this is because I found, having installed Python 3.6 in my Cygwin setup, that I had to use pip3, not pip
, to install Django.
我提到这一切的原因是因为我发现,在我的 Cygwin 设置中安装了 Python 3.6,我必须使用pip3而不是pip
来安装 Django。
My installed version of Django was 1.11.8. To follow the "official" (?) tutorial herethey want you to have Django 2.0 installed. I successfully managed to do this with:
我安装的 Django 版本是 1.11.8。要按照此处的“官方”(?)教程进行操作,他们希望您安装 Django 2.0。我成功地做到了这一点:
$ pip3 install -U django
Hope this helps someone. Perhaps someone much more knowledgeable than me can talk about the need or otherwise to use pip3
for all Python 3.x activity???
希望这可以帮助某人。也许比我知识渊博的人可以谈论是否需要或以其他方式pip3
用于所有 Python 3.x 活动???
回答by Mustapha-Belkacim
pip install --upgrade django
works just fine, but before upgrading it's highly recommended to read this part from the documentation: https://docs.djangoproject.com/en/2.1/howto/upgrade-version/
工作得很好,但在升级之前强烈建议从文档中阅读这部分:https: //docs.djangoproject.com/en/2.1/howto/upgrade-version/
回答by Alireza.mor
You can use this command in vitualenv:
你可以在 vitualenv 中使用这个命令:
`pip install django==<version>`
this should work.
这应该有效。
回答by ErwanKRUG
with python 3.7 try:
使用 python 3.7 尝试:
sudo pip3 install --upgrade django==2.2.6
Because using the following:
因为使用以下内容:
pip3 install -U django
or with python 2.7 if you like to keep that old python:
或者使用 python 2.7,如果你想保留旧的 python:
pip install -U django
Only gives you the older version of django (1.11.xx instead of 2.2.6)
只给你旧版本的 django(1.11.xx 而不是 2.2.6)