1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Why does Visual Studio Code recognize numpy but not matplotlib.pyplot in Python?

Discussão em 'Python' iniciado por Stack, Maio 8, 2025.

  1. Stack

    Stack Membro Participativo

    In Visual Studio Code, I can use numpy library but not the matplotlib.pyplot library even though I have installed both

    The example code in visual studio code:

    mport matplotlib.pyplot as plt

    import numpy as np

    xpoints = np.array([0, 6])
    ypoints = np.array([0, 250])
    plt.plot(xpoints, ypoints)

    plt.show()


    I get in the terminal

    ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package

    However, when I type pip3 show matplotlib, I get the message that it is alr installed:

    Name: matplotlib
    Version: 3.7.1
    Summary: Python plotting package
    Home-page: https://matplotlib.org
    Author: John D. Hunter, Michael Droettboom
    Author-email: matplotlib-users@python.org
    License: PSF
    Location: /home/huinker/.local/lib/python3.10/site-packages


    However, VS code works with other library like numpy. Example code

    import numpy
    A, B=numpy.array(list(map(int, input().split()))), numpy.array(list(map(int, input().split())))
    print (numpy.inner(A, B))
    print (numpy.outer(A, B))


    the code works with numpy library. when i try in the termial pip3 show numpy:

    Name: numpy
    Version: 1.24.3
    Summary: Fundamental package for array computing in Python
    Home-page: https://www.numpy.org
    Author: Travis E. Oliphant et al.
    Author-email:License: BSD-3-Clause
    Location: /home/huinker/.local/lib/python3.10/site-packages
    Requires:
    Required-by: contourpy, matplotlib


    What is my problem with the environment?

    Continue reading...

Compartilhe esta Página