profile
viewpoint

Ask questionsWorkspace contains pipfile but pipenv --venv failed

<!-- Do you have a question instead of a bug report or enhancement request? Please ask it on https://stackoverflow.com/questions/tagged/visual-studio-code+python.

Unable to install a linter or formatter? 'No installers available'? Windows - https://stackoverflow.com/questions/4750806/how-do-i-install-pip-on-windows Linux - https://www.cyberciti.biz/faq/debian-ubuntu-centos-rhel-linux-install-pipclient/ , https://www.tecmint.com/install-pip-in-linux/

Python configuration issues? Please check https://code.visualstudio.com/docs/python/python-tutorial#_prerequisites

Otherwise please fill in the requested details below. "XXX" markers should not be present in the final bug report.

If you think a GIF of what is happening would be helpful, consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ . -->

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
microsoft/vscode-python

Answer questions shantiscript

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??

useful!
source:https://uonfu.com/
Github User Rank List