0

i use vscode on windows10. I just created a Django project+app like this: In the vscode powershell terminal:

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

because of the server running in my powershell terminal i take a second powershell terminal and continue with activating the venv and creating a app.

.\scripts\activate
python manage.py startapp api_order_app #creating a app called api_order_app

When i now open the models.py python is reporting an problem "E0401:Unable to import 'django.db'" Same for all other imports in every other script.

What did go wrong? I did this twice always the same problem. This is how it looks like in the IDE

<img src="https://i.stack.imgur.com/JTmvb.jpg">

Thanks in Advance for helping me out.

Ben

1 Answers1

1

I figured it out... I wasnt on the right virtualenvironment. But Django was only installed at the venv. In Visual Studio Code you can choose the environment u want to use in the bottom left corner. enter image description here

Now everything works just fine.

rkta
  • 3,959
  • 7
  • 25
  • 37