1

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"
}
5
  • 1. In your workspace you should have a .vscode folder and in that a .settings file (name may be a bit different, recalling from memory). In there is should say what your used python interpreter path is. 2. You have multiple python version installed. You can check the path of your python interpreter with which python (or which ipython). In your VSC commando (second picture) select "Enter interpreter path..." Commented Sep 23, 2020 at 11:37
  • Just added .json and python path. Yeah, I have multiple python interpreter installed. But the path are correct. It's working fine before. Commented Sep 23, 2020 at 12:54
  • Did you consult the relevant documentation ? If I understand correctly, python.condaPath should be the path to the Conda executable, not the Python installation in an environment. Setting the python.pythonPath to the Python in the environment might not be sufficient for it to work correctly, either. Commented Sep 23, 2020 at 19:26
  • @AMC Yeah, I am pointing to the executable. I think you might be referring to python.exe file? That's understand Windows. In Linux, it is just python. Commented Sep 24, 2020 at 8:23
  • I think you might be referring to python.exe file? That's understand Windows. In Linux, it is just python. Which part of my comment are you referring to? Commented Sep 24, 2020 at 20:25

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.