0

Solution: I had a sneaky system environment variable that put the 3.10 python variable into the path. Deleted that variable.

I'm super new and trying to import modules like matplotlib to Python. When I hit "run python file", the terminal produces exactly what I want, confirming the import worked. But when I hit "run code" I get the following in the output:

Traceback (most recent call last):
File "c:\Users\user\AppData\Local\Programs\Python\Python39\Workpls\test.py", line 1, in module
import matplotlib
ModuleNotFoundError: No module named 'matplotlib'"

This is the code I ran in both terminal and output:
import matplotlib
help(matplotlib)

For more context: It appears I have two python folders of differing versions (v3.9 & v3.10) in my APPDATA/Local/Programs folder. In VSCode I changed everything to the one of interest(v3.9): the vscode default python interpreter path, the interpreter in the blue ribbon at the bottom of vscode, and the command palette Python: Select Interpreter (note that for some reason it still shows v3.10 as the global version in the palette drop down). Yet it still doesn't produce the desired output.

1
  • Try to uninstall one/both of the python versions then reinstall. Including reinstalling all libraries Commented May 3, 2022 at 19:32

1 Answer 1

0

I think this should be related to the confusion of your Python version. I suggest you leave only one Python version, and you can put another version into the virtual environment.

At the same time, we recommend using run Python file. After all, code-runner is not the official extension of Microsoft.

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.