簡體   English   中英

VS 代碼未加載 Python 解釋器

[英]VS code not loading Python Interpreter

這是我的 VS 代碼信息:

Version: 1.43.2 (user setup)
Commit: 0ba0ca52957102ca3527cf479571617f0de6ed50
Date: 2020-03-24T07:38:38.248Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.17763

我的python路徑在這里:

/auto/energymdl2/anaconda3/envs/commod_py3_20200921/bin/python

但是即使在我選擇之后,VS 代碼仍然在狀態欄中說Select Python Interpreter 在此處輸入圖片說明

但是當我嘗試選擇時,它說它已經被選擇了。 目前,由於這個原因,我無法使用 Python linter Flake8。 在此處輸入圖片說明

當我檢查控制台日志時。 我得到了以下內容。

Error Python Extension: 2020-09-23 05:02:01: Failed to parse interpreter information for /auto/energymdl2/anaconda3/envs/commod_py3_20200921/bin/python,/home/test/.vscode-server/extensions/ms-python.python-2020.5.86806/pythonFiles/pyvsc-run-isolated.py,/home/test/.vscode-server/extensions/ms-python.python-2020.5.86806/pythonFiles/interpreterInfo.py stderr: Error in sitecustomize; set PYTHONVERBOSE for traceback:ModuleNotFoundError: No module named 'sdlc'

但是當我進入 Python 並導入sdlc 時 我能夠。 Python/iPython 路徑:

/auto/energymdl2/anaconda3/envs/commod_py3_20200921/bin/python

在此處輸入圖片說明 這是我的 setting.json 中的內容

{
  "python.linting.pycodestyleEnabled": false,
  "python.linting.flake8Enabled": true,
  "python.linting.enabled": true,
  "python.linting.flake8Args": [
    "--ignore=W605",
    "--ignore=W503",
    "--ignore=W605",
    "--max-line-length=120"
  ],
  "python.linting.banditEnabled": false,
  "python.pythonPath": "/auto/energymdl2/anaconda3/envs/commod_py3_20200921/bin/python",
  // "python.condaPath": "/auto/energymdl2/anaconda3/envs/commod_py3_20200727/bin/python"
}

事實證明,在$your_conda_env_path/lib/python3.6/site-packages/sitecustomize.py中有一些邏輯可以在工作$your_conda_env_path/lib/python3.6/site-packages/sitecustomize.py中導入用戶定義的包。 但是工作目錄環境變量設置不正確。 我在 repo 根目錄下創建了一個 .env 文件並添加了相關的 env 變量。 它解決了這個問題。

所以實際上所有的 conda 環境都被檢測到了。 只是當它嘗試加載它們時,它會遇到 ModuleNotFoundError。

暫無
暫無

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

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