Skip to content
Advertisement

VS code not loading Python Interpreter

Here is my VS code infor:

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

My python path is here:

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

But VS codes keeps saying Select Python Interpreter in the status bar even after I selected. enter image description here

But when I try to select, it says it is already being selected. At moment, due to this, I am unable to use Python linter Flake8. enter image description here

When I check the console log. I got the following.

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'

But when I go into Python and import sdlc. I am able to. Python/iPython path:

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

enter image description here Here is what I have in my 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"
}

Advertisement

Answer

It turned out that there is some logic goes into $your_conda_env_path/lib/python3.6/site-packages/sitecustomize.py that imports user-defined packages in working repo. But the working directory env variable was not set properly. I created a .env file under repo root dir and added relevant env variables. It resolved the issue.

So in fact all the conda envs were detected. It is just when it tries to load them, it hits ModuleNotFoundError.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement