vscode-python: Workspace contains pipfile but pipenv --venv failed

This is related to #2968, but that’s closed to maintainer comments only. I can reproduce this. I haven’t noticed this bug in a while as my environments are already created and specified in my config files. I encountered this when I was setting up my remote container environment.

Environment data

  • VS Code version:Version 1.35.0-insider (1.35.0-insider)
  • Extension version (available under the Extensions sidebar): 2019.4.12954
  • OS and version: macOS 10.14.4 (18E226)/Ubuntu 19.04 (4.9.125-linuxkit)
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.7.3 installed via pyenv
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): pipenv
  • Relevant/affected Python packages and their versions: N/A

Expected behaviour

pipenv --venv runs without failing allowing the extension to either create a new environment or choose the existing environment as the python interpreter

Actual behaviour

pipenv --venv fails because it cannot be found on the path

Steps to reproduce:

  1. Create a new project with a Pipfile and Pipfile.lock.
  2. Open that project in code and open a python file
  1. As the python extension loads it will run pipenv --venv this fails

Logs

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

Starting Microsoft Python language server.
Starting Jedi Python language engine.
Diagnostic Code: InvalidPythonInterpreterDiagnostic, Message: No Python interpreter is selected. You need to select a Python interpreter to enable features such as IntelliSense, linting, and debugging.


Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

Python Extension: Error in invoking PipEnv Error: Traceback (most recent call last):
  File "/root/.pyenv/versions/3.7.3/bin/pipenv", line 10, in <module>
    sys.exit(cli())
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/cli/command.py", line 140, in cli
    do_py()
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/core.py", line 1635, in do_py
    click.echo(which("python", allow_global=system))
  File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/core.py", line 108, in which
    raise RuntimeError("location not created nor specified")
RuntimeError: location not created nor specified
	at y.invokePipenv (/root/.vscode-remote/extensions/ms-python.python-2019.4.12954/out/client/extension.js:83:656368)
	at process._tickCallback (internal/process/next_tick.js:68:7)
t.log @ workbench.main.js:238
$logExtensionHostMessage @ workbench.main.js:3180
_doInvokeHandler @ workbench.main.js:3254
_invokeHandler @ workbench.main.js:3254
_receiveRequest @ workbench.main.js:3253
_receiveOneMessage @ workbench.main.js:3251
_protocol.onMessage.e @ workbench.main.js:3250
fire @ workbench.main.js:77
a @ workbench.main.js:321
e @ workbench.main.js:321
fire @ workbench.main.js:77
_receiveMessage @ workbench.main.js:330
S._socketDisposables.push._socketReader.onMessage.e @ workbench.main.js:327
fire @ workbench.main.js:77
acceptChunk @ workbench.main.js:324
_register._socket.onData.e @ workbench.main.js:323
t @ workbench.main.js:332
emit @ events.js:182
addChunk @ _stream_readable.js:279
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onread @ net.js:636
workbench.main.js:238 [Extension Host] Python Extension: Relevant Environment Variables {
    "LC_ALL": "C.UTF-8",
    "LANG": "C.UTF-8",
    "PATH": "/root/.vscode-remote/bin/6ac87465f297a9068bf767f45d6f372fc5697de9/bin:/root/.pyenv/shims:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
}

Location of pipenv

root@9f5aa375bdf8:/workspace# which pipenv
/root/.pyenv/shims/pipenv

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15

Most upvoted comments

@DonJayamanne I’ll give this a try sometime this week, celebrating pride this weekend 🌈🍰🌈

After adding

python.pipenvPath python.pythonPath

manually i get a new error:

Workspace contains Pipfile but the associated virtual environment has not been setup. Setup the virtual environment manually if needed.

even though the environment is setup and works just fine??