简体   繁体   中英

Pip Django Version Different than Python's

I am currently trying to complete the Django tutorial found here: https://docs.djangoproject.com/en/1.9/intro/tutorial01/

However, when I try to run python manage.py migrate I get the error Unknown command: 'migrate' . I looked this up and discovered that this means I am using a version of Django that doesn't support migrate. So I ran python -c "import django; print(django.get_version())" to see what version of Django Python was using. Turns out it's 1.6.1. This doesn't make sense though because when I do pip list I get Django (1.9.2). If I look in my settings.py file it even says "Generated by 'django-admin startproject' using Django 1.9.1."

Does anyone know why Python is using a different version of Django than is installed using pip?

It's highly recommended that you run Django in a virtual environment as it will make managing Django a lot easier, and you don't want to mess with the python version on your system.

use virtualenv -p /usr/bin/python3.5 <path/to/new/virtualenv/> to use virtualenv with a specific python version.

Then pip install Django to get the latest version of Django.

Edit:

Don't forget that when you're messing with Django settings and files, that you need to activate your virtualenv in your command prompt.

Type source myprojectenv/bin/activate and your prompt should change to

(myprojectenv)user@host:~/myproject$

Maybe your using diferent version of python python2 and python3 can have diffent versions of libraries. Try run python3 manage.py migrate

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