简体   繁体   中英

download django 1.10 to python 3.5

How do I download django for python 3.5? When I run my virtual environment and type:

pip install Django

I get:

Requirement already satisfied (use --upgrade to upgrade): django in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

I noticed the problem when using PyCharm. PyCharm shows Django installed in Python 2.7, but not in 3.5. How do I pip install django into 3.5?

My main python package is 2.7. My work uses 2.7, and is migrating towards 3.5. So I'll need both, and would like to keep 2.7 as the default.

You created your virtualenv with Python 2.7. You should first create a virtualenv with Python 3.5

virtualenv -p <path/to/python3.5> <path/to/new/virtualenv>

Then activate this new virtualenv, and finally, run pip install django on the virtualenv with Python 3.5

You can have as many virtual environments as you wish, but each virtualenv can only hold a single Python installation; if you don't specify a Python interpreter, the default one will be used to create the virtualenv (in your case, the default is 2.7)

Try using:

pip3 install Django or even pip3.5 install Django

This is what I used, as pip alone picks up python2 pip. I have Django installed for both python2 and python3.

the easiest to install any version of Django and python(linux) is by installing virtualenvwrapper for python: here we go, first open your console and type following command: 1- sudo pip install virtualenvwrapper 2-→ which virtualenvwrapper.sh /usr/local/bin/virtualenvwrapper.sh(in my case)

   3-which virtualenvwrapper_lazy.sh

/usr/local/bin/virtualenvwrapper_lazy.sh

After this I had to configure a couple of things. First of all I have created a directory for the Python Virtual Environments: mkdir ~/.virtualenvs

have also added an environment variable to my shell. I use bashshell,then If you are using a standard shell, like bash, you need to add the configuration to your ~/.bashrc file.

export WORKON_HOME=$HOME/.virtualenvs I also had to add a command to the ~/.bashrc to run the activation script when my shell starts: --> source /usr/local/bin/virtualenvwrapper_lazy.sh Finally to create a new virtual environment, for example if you want to create mytest virtualenvironment ,you just need to type this command from the terminal:

mkvirtualenv mytest

and that's all

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM