Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
115 views
in Technique[技术] by (71.8m points)

Visual Studio Code run venv python

I created a venv in python. In CMD I can execute it with

PythonpyenvScriptsactivate

and run my Scripts after that

python example.py

But how do I do it automatically in Visual Studio Code? If I press F5 or CTRL+F5 VSC tries to run another Python version but not my venv. In settings.json I have path to my venv:

{
"python.pythonPath": "Python\pyver\py391\python.exe"
}

I need to write somewhere in my setting the PythonpyenvScriptsactivate and execute it with python like Anaconda is doing it. I can see in my terminal if I press F5 with Anaconda it runs firstpathoScriptsactivate and after that it activade conda base and runs the python script. How do I set my setting like in Anaconda?

Thank you in advance :)

question from:https://stackoverflow.com/questions/65873338/visual-studio-code-run-venv-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to select the interpreter: https://code.visualstudio.com/docs/python/environments


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...