Django 2.1.1导入错误
我在windows10上使用vscode。我刚刚创建了一个Django project+应用程序,如下所示: 在vscode powershell终端中:Django 2.1.1导入错误,django,import,importerror,django-2.0,python-3.7,Django,Import,Importerror,Django 2.0,Python 3.7,我在windows10上使用vscode。我刚刚创建了一个Django project+应用程序,如下所示: 在vscode powershell终端中: python -m venv venv #createing a virtual environment called venv .\scripts\activate #activate the virtual environment pip install django==2.1.1 #install the newest versio
python -m venv venv #createing a virtual environment called venv
.\scripts\activate #activate the virtual environment
pip install django==2.1.1 #install the newest version of Django
python -m pip install --upgrade pip #upgrading pip
pip install requests #install requests for api-requests
django-admin startproject api_order . #creates a django project called api_order
python manage.py migrate #create database
python manage.py runserver #starting the server
由于服务器在我的powershell终端中运行,我使用第二个powershell终端,继续激活venv并创建应用程序
.\scripts\activate
python manage.py startapp api_order_app #creating a app called api_order_app
当我现在打开models.py时,python报告了一个问题“E0401:无法导入'django.db'”,对于其他脚本中的所有其他导入都是如此
出了什么问题?
我做了两次同样的问题。
我想出来了。。。我不是在正确的虚拟环境中。但Django仅安装在venv上。
在VisualStudio代码中,您可以在左下角选择要使用的环境。
现在一切正常