https://python-poetry.org/docs/#installation
pipx install poetry
Can also pipx upgrade poetry
or pipx uninstall poetry
poetry env use 3.9
Make sure that your terminal folder is located in project root. Then run following command:
poetry env use 3.9
You just need to type in your shell:
poetry config virtualenvs.in-project true
The virtualenv will be created inside the project path and vscode will recognize. Consider adding this to your .bashrc or .zshrc.
If you already have created your project, you need to re-create the virtualenv to make it appear in the correct place:
poetry env list # shows the name of the current environment
poetry env remove <current environment>
poetry install # will create a new environment using your updated configuration
Remember the install path for following step.
Original: https://stackoverflow.com/questions/66869413/visual-studio-code-does-not-detect-virtual-environments
-
In VSCode open your command palette — Ctrl+Shift+P by default
-
Look for Python: Select Interpreter
-
In Select Interpreter choose Enter interpreter path... and then Find...
-
Navigate to your venv folder — eg, ~/pyenvs/myenv/ or \Users\Foo\Bar\PyEnvs\MyEnv\
-
In the virtual environment folder choose /bin/python or /bin/python3
If you go to the Settings( Ctrl + , ) you can see the search bar. There, put in 'Send Selection To Interactive Window' or the like, and click the checkbox of 'Python › Data Science: Send Selection To Interactive Window'. After that, you would be able to run certain lines directly in the Interactive Window.