skip to Main Content

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?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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:

    status bar of VS code displaying the Python version

    Now, click on the Python version number, which opens this interpreter selection:

    Python interpreter selection of VS code

    In gray, you see the path of the used Python. Finally, run the following in your PowerShell:

    Get-Command python
    

    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:

    /usr/bin/python -m pip install seaborn
    

    This forces the package installation in the Python version that my VS Code uses.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search