Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to import Django.shortcuts

I was working on my first django project using the documentation. I am getting this error while importing django modules. I'm sure that django is successfully installed in my virtual environment. The error is:

THE SCREENSHOT OF THE ERROR

Unable to import 'django.shortcuts'
Unable to import 'django.http'
Unable to import 'django.contrib'
Unable to import 'django.urls'
like image 335
Gurpartap Singh Avatar asked Jan 18 '20 11:01

Gurpartap Singh


3 Answers

If you look in your status bar you will notice you selected your global install of Python 3.7.4 and not a virtual environment. If you click on that you can then choose your virtual environment that you installed Django into.

like image 145
Brett Cannon Avatar answered Nov 16 '22 00:11

Brett Cannon


enter image description here

You selected your global install of Python 3.7.4 and not a virtual environment. If you click on that you can then choose your virtual environment that you installed Django into.

enter image description here

like image 37
Raghavendara Avatar answered Nov 15 '22 22:11

Raghavendara


Screenshot

Solution 2: (open VS Code from an activated virtual environment):

  1. Open the terminal window
  2. Activate the relevant python virtual environment
  3. Ensure Pylint is installed within this virtual environment pip install pylint
  4. Close all instances of VS Code
  5. Launch VS Code from within this terminal window

(this will ensure the VS Code process will inherit all of the Virtual Env environment settings)

like image 34
Raj Kushwaha Avatar answered Nov 16 '22 00:11

Raj Kushwaha