Reputation: 3677
I am a noob to vs-code (starting using it yesterday and I like it)
I have a minor irritation. I am working on a django project and I'm using a virtualenv with virtualenvwrapper. The problem that I have is that (for example) in the line
from django.shortcuts import render
the linter says
Unable to import 'django.shortcuts'pylint(import-error)
My virtualenvs are in the directory ~/Envs and
ls -l Envs
returns
drwxr-xr-x 4 jeff jeff 4096 Jun 18 14:46 django
-rwxr-xr-x 1 jeff jeff 135 Jun 18 15:23 get_env_details
-rw-r--r-- 1 jeff jeff 96 Jun 18 15:23 initialize
-rw-r--r-- 1 jeff jeff 73 Jun 18 15:23 postactivate
-rw-r--r-- 1 jeff jeff 75 Jun 18 15:23 postdeactivate
-rwxr-xr-x 1 jeff jeff 66 Jun 18 15:23 postmkproject
-rw-r--r-- 1 jeff jeff 73 Jun 18 15:23 postmkvirtualenv
-rwxr-xr-x 1 jeff jeff 110 Jun 18 15:23 postrmvirtualenv
-rwxr-xr-x 1 jeff jeff 99 Jun 18 15:23 preactivate
-rw-r--r-- 1 jeff jeff 76 Jun 18 15:23 predeactivate
-rwxr-xr-x 1 jeff jeff 91 Jun 18 15:23 premkproject
-rwxr-xr-x 1 jeff jeff 130 Jun 18 15:23 premkvirtualenv
-rwxr-xr-x 1 jeff jeff 111 Jun 18 15:23 prermvirtualenv
drwxr-xr-x 4 jeff jeff 4096 Jun 18 15:26 wagtail
I am working in the venv django
I have tried setting the Python: Venv Path and/or Python: Venv Folders to ~/Envs and ~/Envs/django. I have restarted vs-code, but the problem persists
What should I do?
Upvotes: 0
Views: 171
Reputation: 1707
Try setting the Python Interpreter to the option with venv
.
Upvotes: 0
Reputation: 1063
did you tried like this : To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).
You can switch environments at any time; switching environments helps you test different parts of your project with different interpreters or library versions as needed.
The Python: Select Interpreter command displays a list of available global environments, conda environments, and virtual environments. (See the Where the extension looks for environments section for details, including the distinctions between these types of environments.) The following image, for example, shows several Anaconda and CPython installations along with a conda environment and a virtual environment (env) that's located within the workspace folder:
sources: https://code.visualstudio.com/docs/python/environments
Upvotes: 1