简体   繁体   中英

django-admin.py not running

I'll add another django-admin.py question, as none of the other questions seem to cover my issue:

I've installed django via pip:

$ pip install django

My pip and Python versions are:

$ pip -V
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

Specifically, python is version 2.7.14. At this point I expected to run

$ django-admin startproject myTestProject

which would then create my project folders in the current directory.

However, this returns

Cannot find installed version of python-django or python3-django

This confuses me, since when I ran

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Further, I checked where the file django-admin.py is located:

$ find -iname "django-admin.py"
./.local/bin/django-admin.py
./.local/lib/python2.7/site-packages/django/bin/django-admin.py

So it seems like django-admin.py is in my PATH. Why then can I not run it?

(extra info: I do have python 3.6.3 installed, too. But I don't think this version has anything to do with pip or django.)

I recommend you always use a virtual environment manager with your Django projects, such as virtualenvwrapper ( pip install virtualenvwrapper or sudo pip install virtualenvwrapper see here for installation instructions)

then you can mkvirtualenv myprojectname and install django into the virtual environment ( pip install django ). then you will not face any problems such as this

So, there are a few things,

  1. You should be looking for django-admin not django-admin.py .
  2. Your paths have /usr/local/bin , what you're looking at is /home/<your user>/.local which is certainly not the right place.
  3. As everybody suggested, use virtualenv for maintaining your projects and its dependencies cleanly and nicely.

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