簡體   English   中英

WSL2 中的 VSCode Python 擴展 - 錯誤:無法獲取“~/.pyenv/shims/python3.6”的解釋器信息

[英]VSCode Python Extension in WSL2 - Error: Failed to get interpreter information for '~/.pyenv/shims/python3.6'

我在 WSL2:Ubuntu 20.04 中進行 Python/Django 開發。 使用code. ,Python 擴展卡住了消息“Python 擴展加載...”。 在 Output 部分,出現以下代碼:

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

我通過將 Python 擴展的版本降級為v2021.1.502429796解決了這個問題。 希望這會在某個時候得到解決。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM