WSL2中的VSCode Python扩展错误:无法获取“~/.pyenv/shimmes/python3.6”的解释器信息

2024-06-07 06:13:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在WSL2:Ubuntu 20.04中进行Python/Django开发。使用code .打开VSCode时,Python扩展会被消息“Python扩展加载…”卡住。在输出部分,将显示以下代码:

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - experiment'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'AA_testing - experiment'
User belongs to experiment group 'LocalZMQKernel - experiment'
User belongs to experiment group 'CollectLSRequestTiming - control'
User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
User belongs to experiment group 'EnableIPyWidgets - experiment'
User belongs to experiment group 'RunByLine - experiment'
User belongs to experiment group 'CustomEditorSupport - control'
Error 2021-01-23 12:33:35: Failed to initialize source map support in extension
User belongs to experiment group 'pythonaacf'
User belongs to experiment group 'pythonJoinMailingListVar2'
User belongs to experiment group 'pythonSendEntireLineToREPL'
User belongs to experiment group 'pythonInstallPylintButtonFirst'
> conda --version
> conda info --json
> python3.7 ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Error 2021-01-23 12:33:37: Detection of Python Interpreter for Command python3.6 and args  failed as file  does not exist
Error 2021-01-23 12:33:39: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://wsl+ubuntu-20.04/home/ben/.config/Code/User/settings.json' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/home/ben/.config/Code/User/settings.json')
    at _handleError (/home/ben/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/out/vs/server/remoteExtensionHostProcess.js:769:473)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async y.readText (/home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/out/client/extension.js:9:344778)
    at async p.doesFileNeedToBeFixed (/home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/out/client/extension.js:59:500280)
    at async /home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/out/client/extension.js:59:499407
    at async Promise.all (index 0)
    at async p.getFilesToBeFixed (/home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/out/client/extension.js:59:499353)
    at async p.updateTestSettings (/home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/out/client/extension.js:59:498980)] {
  code: 'FileNotFound',
  name: 'EntryNotFound (FileSystemError)'
}
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py pylint --load-plugins pylint-flask --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/Code/eons-website/eons_backend/eons_data/models.py
cwd: ~/Code/eons-website
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py pylint --load-plugins pylint-flask --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/Code/eons-website/eons_backend/eons_data/models.py
cwd: ~/Code/eons-website
Python interpreter path: ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python
Starting Jedi Python language engine.
> conda --version
##########Linting Output - pylint##########
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.prefix)"
cwd: ~/Code/eons-website
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.prefix)"
cwd: ~/Code/eons-website
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
cwd: ~/Code/eons-website
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
cwd: ~/Code/eons-website
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: ~/Code/eons-website
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: ~/Code/eons-website
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py site --user-site
cwd: ~/Code/eons-website
> ~/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python ~/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py site --user-site
cwd: ~/Code/eons-website
Error 2021-01-23 12:33:40: Failed to get interpreter information for '/home/ben/.pyenv/shims/python3.6' [Error: Command failed: "/home/ben/.pyenv/shims/python3.6" "/home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py" "/home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/interpreterInfo.py"
pyenv: python3.6: command not found

The `python3.6' command exists in these Python versions:
  3.6.12

Note: See 'pyenv help global' for tips on allowing both
      python2 and python3 to be found.

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:223:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:223:5)
    at Pipe.<anonymous> (net.js:664:12)] {
  killed: false,
  code: 127,
  signal: null,
  cmd: '"/home/ben/.pyenv/shims/python3.6" "/home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py" "/home/ben/.vscode-server/extensions/ms-python.python-2021.1.502429796/pythonFiles/interpreterInfo.py"'
}

我曾尝试卸载扩展并重新安装它-有时这似乎有效,但大多数情况下无效。我还手动删除了“~/.vscode server/extensions”中的所有扩展文件,但这也不起作用

pyenv中查找python3.6命令时,它似乎挂断了,但我不需要它来查找这个可执行文件。我正在使用的环境在~/.local/share/virtualenvs/<env-name>/bin中有自己的python可执行文件,当前版本为3.8.5

这是在本地.vscode/settings.json文件中定义的:

{
    "python.pythonPath": "/home/ben/.local/share/virtualenvs/eons_backend-AMh9NQBG/bin/python",
}

我应该如何配置扩展以忽略Python的pyenv安装


Tags: torunpyhomeserversysextensionsvscode