pip 在 python3.6 上安装 Django

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41588925/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 01:17:01  来源:igfitidea点击:

pip install Django on python3.6

pythondjangopython-3.xpippython-3.6

提问by davideghz

If I run pip install DjangoI get

如果我跑pip install Django我得到

Requirement already satisfied: Django in /usr/local/lib/python2.7/dist-packages

需求已经满足:/usr/local/lib/python2.7/dist-packages中的Django

I'd like to use python3.6 instead (which is already installed in /usr/bin/python3.6). What's the correct pipsyntax to install the last version of Django on python 3.6?

我想改用 python3.6(已安装在 中/usr/bin/python3.6)。pip在 python 3.6 上安装最新版本的 Django的正确语法是什么?

采纳答案by Essex

You have to install pip3 :

您必须安装 pip3 :

sudo apt-get install python3-pip

Then, you have to work with venv

然后,你必须与 venv

pip3 -p python3.6 virtualenv name

And you have to write :

你必须写:

pip3 install Django

#or specific version
pip3 install Django==1.10.5

回答by Shivkumar kondi

If you have pip3then directly use

如果您有pip3则直接使用

pip3 install Django

pip3 install Django

Else try to use virtualenvfor your python version as :

否则尝试将virtualenv用于您的 python 版本:

pip -p python3.6 virtualenv name

pip -p python3.6 virtualenv name

then you can install any version of Django on it.

然后您可以在其上安装任何版本的 Django。

回答by hspandher

You can install it globally as others suggested, but the recommended way to install it is to use virtualenv or venv. In case you are using virtualenv (with virtualenvwrapper), just do

您可以按照其他人的建议全局安装它,但推荐的安装方法是使用 virtualenv 或 venv。如果您使用的是 virtualenv(使用 virtualenvwrapper),只需执行

mkvirtualenv --python="path to python3 executable" "environment name"
pip install django

Inside virtual environment pipwould be pip3by default and so is python.

内部虚拟环境pippip3默认为python.

回答by Dimitris Fasarakis Hilliard

As is common with these sort of pipissues, before you install, check where pipis pointing to with pip -V.

由于是与这些类的常见pip问题,请在安装之前,检查这里pip正指向pip -V

If that points to Python 2, you can then try pip3 -V; if that points to an older version of Python 3, go for pip3.6.

如果这指向 Python 2,那么您可以尝试pip3 -V;如果这指向旧版本的 Python 3,请选择pip3.6.

As a final approach, you can always go through pythonitself with python3.6 -m pip install ...

作为最后一种方法,您始终可以python使用python3.6 -m pip install ...

回答by Robert Lu

It means you already installed django in python2.7.

这意味着您已经在python2.7中安装了django。

You can install django for python3 via:

您可以通过以下方式为 python3 安装 django:

pip3 install Django


You can also activate virtualenv, and run pip install Django

您还可以激活 virtualenv,然后运行 pip install Django