0

I am importing matplotlib the following way:

import matplotlib.pyplot as plt

Then when I execute the command:

fig = plt.figure(figsize=(10, 10))

I get the following error:

TypeError: 'module' object is not callable

I don't understand why it could be happening, as I always import pyplot like that and I never have any issues.

When printing plt I obtain the following:

<module 'matplotlib' from 'C:\\Users\\itsas\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\matplotlib\\__init__.py'>

When I substitute all my 'plt' for 'matplotlib.pyplot', it works... It's almost as if it wasn't importing pyplot for some reason...

6
  • 1
    Try printing 'plt' and add the output to your question. Commented Feb 22, 2021 at 18:12
  • just have a look on stackoverflow.com/questions/16527149/… ,you will get your answer Commented Feb 22, 2021 at 18:14
  • I included what happens when I print plt! Commented Feb 22, 2021 at 18:17
  • what did import pylab; print pylab.__file__ return ? Commented Feb 22, 2021 at 18:21
  • 1
    You very probably assigned plt.figure = ... either somewhere earlier in your code, or in an interactive environment. Try restarting your environment. Commented Feb 22, 2021 at 18:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.