[Python] Importing python modules works in command line but not in the python 3.8 shell

Discussão em 'Python' iniciado por Stack, Agosto 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm having a problem with importing modules in python. When I run my program in the command line it works perfectly fine. However, when I try to run the same program in the python shell I am prompted with the following error:

    ModuleNotFoundError: No module named 'matplotlib'

    I already successfully installed matplotlib using 'python -m pip install matplotlib'. I've read this can happen when you have two different versions of python installed; however, I don't. I've uninstalled and reinstalled python and I still am having the same issue. I've also uninstalled and reinstalled matplotlib using pip.

    I believe my problem is the module paths that python uses to search for imported modules are different between the two.

    When I use the 'print(sys.path)' command in the python shell and the command line I get two different outputs.

    Any help would be greatly appreciated!!!

    The file different system paths between the python shell and the command line

    Continue reading...

Compartilhe esta Página