0

Can somebody help me with this problem?

  1. Python recognises matplotlib from the command line:

    import matplotlib
    matplotlib.__version__
    '3.4.3'
    
  2. But not from a script

    This is my script (to keep it simple):

    import matplotlib.pylab as plt
    import numpy as np
    

These are the errors:

Traceback (most recent call last):

  File "C:/Program Files/Python39/Scripts/matplotlib.py", line 1, in <module>

    import matplotlib.pylab as plt

  File "C:\Program Files/Python39/Scripts\matplotlib.py", line 1, in <module>

    import matplotlib.pylab as plt

ModuleNotFoundError: No module named 'matplotlib.pylab';
 
'matplotlib' is not a package
Zephyr
  • 11,891
  • 53
  • 45
  • 80

1 Answers1

-1

Try Reinstalling the package or downgrading it to a more stable version like 2.02

  • Thank you very much for taking the time to answer my question. :-) As it turns out renaming my file from matplotlib.py to plotting_with_mat.py worked like a charm. – Theo Lantzakis Sep 03 '21 at 05:11
  • Yes that also might be the problem as you cannot name a file the name of a package as it will not import correctly thus giving an error. – Darsh Cubing Sep 12 '21 at 11:56