I'm work using a virtualenv, the script works and doesn't alert "no module error". Despite VS continue to highlight my import. Can someone explain me why?
Asked
Active
Viewed 746 times
0
-
1You probably need to set a source root to a directory where `torch` is located. – Yevhen Kuzmovych Nov 04 '21 at 12:22
-
If i execute the script in my virtualenv all works correctly.. – Nov 04 '21 at 12:23
-
Does this answer your question? [How can I set up a virtual environment for Python in Visual Studio Code?](https://stackoverflow.com/questions/54106071/how-can-i-set-up-a-virtual-environment-for-python-in-visual-studio-code) – Antoine Nov 04 '21 at 12:25
-
Or this one: https://stackoverflow.com/questions/57333371/how-to-make-vs-code-read-python-imports-without-displaying-yellow-squigglies – David Brabant Nov 04 '21 at 12:26
-
I got that part. That means that source roots are different for VS and wherever you are running your script from. – Yevhen Kuzmovych Nov 04 '21 at 12:26
-
i explain the problem clearly, i have folder A that contains another folder for the virtualEnv. Now my settings json contains only this: "python.analysis.extraPaths": [ "./.vscode-server/extensions/ms-python.vscode-pylance-2021.10.3/dist/bundled/stubs/pandas/compat" ]. I tried to follow yours suggestion..maybe i don't understand..i need to create a .env inside the virtual env folder and add "python.envFile" in settings.json? – Nov 04 '21 at 12:44
-
Can you attach a screenshot of the `PROBLEMS` panel? We want to know what prompts these errors. thanks. – Steven-MSFT Nov 05 '21 at 03:00
-
Could you provide a full screenshot of the VSCode with the `PROBLEMS` panel opened? We want to know which python interpreter you have selected, which prompts the error messages, and If you can provide the terminal panel with the command of executing the python file, that will be great. thanks a lot. – Steven-MSFT Nov 05 '21 at 03:06