Xiaofan
Xiaofan

Reputation: 3

Settings of Virtual Environment in Python with Visual Studio Code

I tried but completely failed to find any useful info on this particular subject on the internet.

I am a beginner in Django. I installed "virtualenv" with pip, and created an environment under "D:\Dropbox\Git\Python\Django_projects" called "env_mysite."

In the Command Prompt, everything works as expected. But now, since I tried to code with Visual Studio Code, I would like to use "Ctrl+Shift+P" to quickly select python interpreter, which in my case would be either the "normal python" or the one in the virtual environment in the D: path aforementioned... it depends on the project.

After googling, I understand it seems that this may be because of the wrong path settings in the User Settings in VS Code.

My current path settings are as below:

python.venvPath and python.pythonPath.

I hope some of you guys can help me with how to set the correct path under Windows.

Appreciated.

Upvotes: 0

Views: 799

Answers (1)

Brett Cannon
Brett Cannon

Reputation: 15990

If your project is under D:\Dropbox\Git\Python\Django_projects and env_mysite is the only virtual environment, then open the Django_projects folder in VS Code and the Python extension will simply discover your virtual environment.

If your code lives elsewhere then you will want to set "python.pythonPath": "D:\\Dropbox\\Git\\Python\\Django_projects\\Scripts\\python.exe".

Upvotes: 1

Related Questions