I switched from a Mac to Windows 11 and have issues with my python scripts or with the packages more precisely. I installed seaborn with pip install seaborn
via PowerShell but when I run import seaborn
in Visual Studio Code I get "No module name seaborn". Similarly installed matplotlib and getting the error "No module named ‘matplotlib.docstring’" when I run import matplotlib.pyplot as plt
. Installed Python 3.10.6 instead of the newest version and now matplotlib is working, but this is not really a good longterm solution and also seaborn still isn’t working. I verified that the interpreter is installed in the same location as everything else, also I installed WSL to use that instead of the PowerShell but nothing changes and I’m out of ideas as to what the issue could be. Does anyone have an idea what’s going on here and how I can ensure a smooth installation without having issues with every single package?
Question posted in Visual Studio Code
View the official documentation.
View the official documentation.
2
Answers
Maybe try the cmd in VSC by opening a new terminal (Terminal -> New terminal) and then executing it. Sometimes, VSC doesn’t find the pkgs installed on system.
Different instances of Python can be installed on your system in parallel. The version that VS Code uses may not be the same that you access in the terminal.
First, verify which version of Python is used in VS Code by checking the status bar at the bottom. You should find something like this:
Now, click on the Python version number, which opens this interpreter selection:
In gray, you see the path of the used Python. Finally, run the following in your PowerShell:
If the output path does not correspond to the one shown in VS Code, you can either select the correct interpreter in VS Code (via the interpreter selection), or install the package in the correct Python environment by specifying the full path.
E.g., in my example, I could run:
This forces the package installation in the Python version that my VS Code uses.