The solution to the error when executing the python manage.py startapp command when Django creates an app package

The solution to the error when executing the python manage.py startapp command when Django creates an app package

Today I encountered an error message when I executed the python manage.py startapp command when creating a Django app package:

python manage.py startapp appname

Traceback (most recent call last): File "manage.py", line 17, in <module> "Couldn't import Django. Are you sure it's installed and " ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

In the process of solving the problem, the first thing that comes to mind according to the prompt is the problem of environment variables. After configuring environment variables for Django, the problem is still not solved. Finally, Google search found that two versions of python are installed will encounter this error. If you want to install through Python 3.x, you need to select pip3 from the absolute path, in case there are other content in the environment variable. The easiest way is to choose the correct pip version from the absolute path like this:

C:\Python3.x\Scripts>pip3 install django

If the problem is still not solved, you can try to upgrade pip and continue to try:

python -m pip install --upgrade pip

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325348437&siteId=291194637