0

When opening a vscode terminal when the python extension is loaded, it tries to execute this:

source /Users/victor/.pyenv/shims/activate.sh

Which triggers this error:

pyenv: activate.sh command not found

The `activate.sh` command exists in these Python versions:
    2.7.4

And then bluntly closes the terminal. Is there an issue with my pyenv installation here?

Context:

  • which python > /Users/victor/.pyenv/shims/python
  • python --verison > Python 3.7.4
  • VSCode: Version: 1.41.1
  • OS: macOS 10.14.6
  • pyenv versions:

      system
      2.7.14
      3.4.3
      3.5.4
      3.6.4
      3.6.6
      3.6.9
    * 3.7.4 (set by /Users/victor/.pyenv/version)
    
  • Problem arises:
    • only in VSCode's integrated terminal (not in other shells or terminals)
    • only when the Python Extension loads the default Python interpreter (/Users/victor/.pyenv/shims/python) => does not occur when it is configured to load a virtualenv's Python interpreter
    • on all Python version I configure with pyenv global
    • except if I select a specific Python interpreter as default (~/.pyenv/versions/3.7.4/bin/python) in which case the terminal is opened with pyenv shell 3.7.4 (see @Brett Canon's comment)
ted
  • 13,596
  • 9
  • 65
  • 107
  • Is the shell you are using in VS Code the same you are comparing to externally? And what is `"python.pythonPath"` set to? If it's set to `/Users/victor/.pyenv/shims/python` then I would undo that and point at a specific version of Python as you should be controlling the Python version in the extension and not externally from it (the extension makes assumptions based on the version selected). – Brett Cannon Feb 07 '20 at 23:52
  • Yes I've configured it to be the same (zsh 5.1 + oh-my-zsh) – ted Feb 08 '20 at 18:57
  • @BrettCannon I've updated my question, you pointed to a good workaround – ted Feb 08 '20 at 20:17

1 Answers1

0

The Python extension doesn't execute anything on your behalf for pyenv. You/pyenv probably added a command to your shell's configuration file which is trying to run that source command and it turns out to not work with 3.7.4 set as your active pyenv version.

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
  • If that's the case then why does it only happens with vscode's integrated terminal? – ted Feb 07 '20 at 04:04
  • I should also add, and I'll update my question accordingly, that this pb does not happen when pthe python extension is configured to use a virtualenv's python interpreter. But it happens for any version of python that I can set with "pyenv global" – ted Feb 07 '20 at 04:06
  • Best I can suggest is open an issue at https://github.com/microsoft/vscode-python. – Brett Cannon Feb 28 '20 at 19:32