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.

Select pyenv environment based on folder .python-version file

See original GitHub issue

Environment data

  • VS Code version: 1.21.1
  • Extension version (available under the Extensions sidebar): 2018.2.1
  • OS and version: macOS 10.13.3
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): pyenv
  • Relevant/affected Python packages and their versions: pyenv 1.2.1

Actual behavior

You have to manually select the pyenv interpreter for each workspace folder.

Expected behavior

It should detect the workspace pyenv interpreter based on the .python-version file present in the workspace folder root.

For example, every folder I have added to my workspace has a .python-version file that pyenv creates when you run pyenv local NAME_OF_VENV in that folder. The file contains a single string which is the name of the folder/symlink in ~/.pyenv/versions/ that should be used.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:106
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
brettcannoncommented, Apr 24, 2018

https://github.com/pyenv/pyenv#choosing-the-python-version has the specification on how pyenv chooses an interpreter by default. I think detecting the file and using it as appropriate seems like a sensible enhancement (maybe even the file traversal to the parent directory, but not as sure on that one).

4reactions
brettcannoncommented, Sep 1, 2021

@djdembeck please make sure to upvote the opening comment as that’s how we determine community interest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Pyenv choose virtualenv directory
In your project directory, create a .python-version file. Assuming you already installed some virtual environment using pyenv-virtualenv ...
Read more >
Setting up your python development environment ...
As shown below, we'll first set the Python environment with pyenv , and then make a couple virtual environments with virtualenvwrapper . Then...
Read more >
Python: Version Management with Pyenv and ...
To list all the available versions of python to be installed use the following command. pyenv install --list. Now choose the version you...
Read more >
Managing Multiple Python Versions With pyenv
This command creates a .python-version file in your current directory. If you have pyenv active in your environment, this file will automatically activate...
Read more >
How to Manage your Python Projects with Pipenv and Pyenv
This will create a .python-version file in the folder indicating the current local ... Set up very quickly a working Python environment.
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