vscode-python: Log the user's environment when the attempt to execute pipenv returns ENOENT

Environment data

  • VS Code version: 1.21.1
  • Extension version (available under the Extensions sidebar): 2018.3.1
  • OS and version: Solus 3.999 (Linux)
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): pipenv

Actual behavior

Getting a warning saying pipenv is not on path.

Workspace contains pipfile but attempt to run 'pipenv --venv' failed with Error: spawn pipenv ENOENT. Make sure pipenv is on the PATH.
which pipenv

$HOME/.local/bin/pipenv

pipenv installed using pip3 install pipenv --user

Expected behavior

Don’t show a warning because it it clearly on my PATH

Steps to reproduce:

  1. pip3 install pipenv --user
  2. export PATH=$PATH:$HOME/.local/bin

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

No output shown

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

No output shown

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 46 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Installing the release version of the extension should work. We released a new version yesterday.

Having exactly the same issue here. VSCode Windows 1.22.2 x64, Shell 1.7.12 Message : “Workspace contains pipfile but attempt to run ‘pipenv --venv’ failed with Error: spawn pipenv ENOENT. Make sure pipenv is on the PATH.”

I don’t think this can be made to work automatically for everyone everywhere, as there’s just too much variety in the kinds of setups people use, especially on Unix-like systems. But I do think users could be made more aware of this type of issues, and they could be given more convenient tools to address them, so I submitted a report to that effect upstream Microsoft/vscode#50465 😃 You’re more than welcome to chime in!

@dlukes thanks for all the exploration! We obviously don’t control the code command, so feel free to report that upstream to VS Code if you would like to see this changed.

And as for the locale issues, we plan to at least log if not warn users when we discover their locale isn’t set such that click will have an issue.

One last thing: I was also getting a UnicodeDecodeError: 'ascii' codec can't decode byte... on a different box running macOS (from click, when VSCode was trying to run pipenv). This pointed to a misconfigured locale, i.e. another type of environment problem. I ran chsh, which informed me that my login shell was bash, and the crux of the biscuit was that I hadn’t bothered to properly configure the locale in bash because I use zsh on that system. Troubleshooting:

  • running code from a zsh command line, the error goes away
  • more generally, changing my login shell to zsh (using chsh) makes the problem go away, irrespective of how VSCode is started

In any case, getting rid of this type of error is about running VSCode in the proper environment, i.e. the one you use in your interactive terminal sessions. These last two posts of mine are just a laundry list of things you might want to check and tweak in order to make that happen 😃

So I just ran into this same issue on Windows 10 and the problem was that VS Code was not picking up the change I made to my $env:PATH in my Profile.ps1 file. If you’re on Windows, make sure that the directory containing pipenv is on your system-level PATH (which can be set by running sysdm.cpl, going to Advanced, Environment Variables..., and then check your Path value).

Please try re-starting VS Code, ensure you have quit VS Code completely for the VS Code process to load the new environment variable. Once done, please test once again.