question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vscode not able to show poetry environments when trying to select interpreters

See original GitHub issue

Type: Bug

I am using poetry to manage my python application. I am letting poetry create the virtualenv in the default location. However when I am trying to select the desired python interpreter from within vscode, its not listing any of my poetry envs. I can see my global python installations and pyenv installations as well but not poetry. I event tried navigating manually but that did not help.

Steps to reproduce

  • pyenv local (to set python version to the one mentioned in .python-version file)
  • pyenv install (to install the py version)
  • poetry env use ~/.pyenv/versions/3.10.8/bin/python
  • poetry install

Expected behaviour

  • Within vscode the py interpreter from the virtual env created by python should be available to select.
  • Once selected all the imports should resolve.

Actual behaviour

  • The desired py env is not listed in the select interpretor dropdown list.

Output of poetry env info


Virtualenv
Python:         3.10.8
Implementation: CPython
Path:           /Users/dmondal/Library/Caches/pypoetry/virtualenvs/hot-escalation-K4Tshkpo-py3.10
Valid:          True

System
Platform: darwin
OS:       posix
Python:   /Users/dmondal/.pyenv/versions/3.10.8

Out of poetry config --list

cache-dir = "/Users/dmondal/Library/Caches/pypoetry"
experimental.new-installer = true
installer.parallel = true
repositories.artifactory.url = "https://packages.atlassian.com/pypi/pypi/simple/"
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/dmondal/Library/Caches/pypoetry/virtualenvs

Environment Data

  • VS Code version: 1.73.1
  • Extension version (available under the Extensions sidebar): v2022.18.2
  • OS and version: macOS 10.15.7
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.8 (pyenv)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): Poetry
  • Relevant/affected Python packages and their versions: Poetry 1.1.13

I have tried keeping the venv inside project root using virtualenvs.in-project = true, that works fine. Issue seems to be with envs in default poetry location.

I have tried the solution presented here: https://github.com/microsoft/vscode-python/issues/16232 I tried adding the setting "python.experiments.optInto": ["All"] but that did not help.

Extension version: 2022.18.2 VS Code version: Code 1.73.1 (6261075646f055b99068d3688932416f2346dd3b, 2022-11-09T02:08:38.961Z) OS version: Darwin x64 19.6.0 Modes: Sandboxed: No

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
karrtikrcommented, Nov 20, 2022

Feel free to open a new issue with details in that case. New release is expected to go out Dec 7th.

0reactions
cossiocommented, Nov 20, 2022

Unfortunately the pre-release version is failing for me due to a different (I think) error.

When is the release version expected to incorporate this fix? Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode doesn't show poetry virtualenvs in select interpreter ...
To find the ~path, enter poetry env info --path in your CLI under the appropriate project folder, then tack on the subdirectory info...
Read more >
Poetry Environment neither automatically detected nor shown ...
To solve this, simply delete the .venv directory, do a poetry install and reopen vscode. Only at first I had to select .venv...
Read more >
Using Python environments in VS Code
Configuring Python Environments in Visual Studio Code. ... right of the Python: Select Interpreter window; otherwise you may not see the environment there....
Read more >
VS Code Python Tooling Gets 'Most Requested' Feature
"If you're using our Insiders build, you will be able select interpreters from environments created using Poetry, as they're now ...
Read more >
Python projects with Poetry and VSCode Part 1
A Virtual Environment is an isolated Python installation designed to avoid filling our base one with libraries we might use for only one ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found