Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

E0401:Unable to import 'django.db'

So i'm studying python crashcourse and after finishing the basics I jumped to the django project.

I created a virtual env, installed django and created an app with manage.py startapp command.

I use Visual Studio Code, and the problem is when I go to models.py it gives an error that it's unable to find django.db module

unable to import error

Now I understand this is because of the file structure, which is as per my research the correct one, and I followed the book carefully, however i don't know how to fix this and I feel that i'm missing something.

This is my file structure for the virtual environment

file structure

Any idea how to fix it ? :)

Thanks in advance

like image 749
Renm Avatar asked Nov 28 '22 13:11

Renm


1 Answers

Thank you Incognos !

To be more specific The solution was :

enter "code ." in the terminal and then a new VS opens. Ctrl+Shift+P -> Select Interpreter select the environment that starts with ./env or .\env run Ctrl+Shift+` to activate it

like image 166
Renm Avatar answered Dec 04 '22 06:12

Renm