pyenv + virtualenv not working - use pyenv activate for all
See original GitHub issueEnvironment data
- VS Code version: 1.30.2
- Extension version (available under the Extensions sidebar): vscode-python 2018.12.1
- OS and version: ubuntu 16.04LTS
- Python version (& distribution if applicable, e.g. Anaconda): any pypy,cpython
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): pyenv
- Relevant/affected Python packages and their versions: None
Expected behaviour
When choosing python interpreter it lists all versions under ~/.pyenv correctly (see png below), but
the ones created with pyenv+virtualenv like pyenv virtualenv 3.7.2 mycoolapp
which creates a venv environment under pyenv using python 3.7.2 with the name mycoolapp.
This should be activated with:
pyenv activate mycoolapp
The ones listed with venv VSC does:
$ source /home/mortenb/.pyenv/versions/mycoolapp/bin/activate
The ones listed with pyenv (the ones created with pyenv install 3.7.2, that downloads, compile and install the specified python version):
$pyenv shell 3.7.2
this works for base versions not for pyenv+virtualenv, but I recommend using pyenv activate for all
$ pyenv help activate
Usage: pyenv activate <virtualenv>
pyenv activate --unset
Activate a Python virtualenv environment in current shell.
This acts almost as same as `pyenv shell`, but this invokes the `activate`
script in your shell.
<virtualenv> should be a string matching a Python version known to pyenv.
Example loading flask on python 3.6.2:
VSC does when opening a terminal:
$ source /home/mortenb/.pyenv/versions/flask/bin/activate
$ which python
/home/mortenb/.pyenv/shims/python
$ python --version
Python 3.7.0
It is wrong version, if it had done this it would have been correct:
$ pyenv activate flask
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(flask) mortenb@mortenb-home1:/dist/sensio/unity-selenium$ which python
/home/mortenb/.pyenv/shims/python
(flask) mortenb@mortenb-home1:/dist/sensio/unity-selenium$ python --version
Python 3.6.2
Pyenv is a terrific technology, we manage full python versioning control within docker containers by a single build parameter. This container tagged with version number we use as base container for all python projects within the company, it makes regression testing and upgrading a oneliner in jenkins:
https://gist.github.com/fenchu/14b8fe5a0c24942f845a35106c7b176a
So please continue supporting it 😃
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:38
- Comments:24 (6 by maintainers)
Top GitHub Comments
Adding
"python.terminal.activateEnvironment": false
to my settings resolved this issue for me.If VSCode can’t properly activate the python versions installed by pyenv, it should not pretend to support them!