简体   繁体   中英

Should django-admin version be same as Django?

I tried to configure my PC for Django course , i have fresh Ubuntu 18.04 :

I followed all steps from the course :

I had newest python pre-installed, Python 3.6.5 so i went :

sudo apt install python3-pip

went ok, then :

pip3 install django==2.0.2 (version suggested by instructor)

that completed as well, then :

django-admin startproject wordcount

and that gave me error :

Command 'django-admin' not found, but can be installed with:

sudo apt install python-django-common

So i tried to install this but it didn't help. so i checked web for answers and i found that i should do :

sudo apt-get install python-django

And after that i could use

django-admin startproject wordcount

and it created a project for me but i saw that some elements of default files are different from what i saw on course video so i check and :

django-admin --version
1.11.11

also django-admin --help

gives me message like this :

Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).

Any ideas what went wrong and how I can fix it?

I see you struggle with this problem. I would recommend you to move to such thing as a virtualenv (or use anaconda for this task). This should solve a numerous other problems you've not ran across yet and this one especially.

Virtual environment allows you to create separate environment, with it's own packet set. Some IDEs (for example, pycharm) provide GUI for it's creation and management.

Update 1:

Thanks to @DhavalSavalia, of course there is also pipenv package, that is a more friendly virtualenv wrapper (unless you have some gui for virtualenv ).

Update 2:

Also, I've noticed that you setting up django using apt. You probably shouldn't do that, because apt often contains old version of python packages. Use pip for as many packages as you can.

The problem is that the pip3-installed packages aren't on the PATH for some reason. There's a few ways to fix this.

  1. Add the pip3 installation location to your $PATH .
  2. Force it to use the version of Django you installed via pip3:

    $ python3 -m django.bin.django-admin startproject wordcount

  3. Use virtualenv or pipenv to create a "virtual" Python installation - complete with it's own Python version and set of libraries.

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