问题
If I run pip install Django
I get
Requirement already satisfied: Django in /usr/local/lib/python2.7/dist-packages
I'd like to use python3.6 instead (which is already installed in /usr/bin/python3.6
). What's the correct pip
syntax to install the last version of Django on python 3.6?
回答1:
You have to install pip3 :
sudo apt-get install python3-pip
Then, you have to work with venv
pip3 -p python3.6 virtualenv name
And you have to write :
pip3 install Django
#or specific version
pip3 install Django==1.10.5
回答2:
If you have pip3 then directly use
pip3 install Django
Else try to use virtualenv for your python version as :
pip -p python3.6 virtualenv name
then you can install any version of Django on it.
回答3:
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
mkvirtualenv --python="path to python3 executable" "environment name"
pip install django
Inside virtual environment pip
would be pip3
by default and so is python
.
回答4:
As is common with these sort of pip
issues, before you install, check where pip
is pointing to with 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
.
As a final approach, you can always go through python
itself with python3.6 -m pip install ..
.
回答5:
It means you already installed django in python2.7.
You can install django for python3 via:
pip3 install Django
You can also activate virtualenv, and run pip install Django
来源:https://stackoverflow.com/questions/41588925/pip-install-django-on-python3-6