Forums

RuntimeError: implement_array_function method already has a docstring

"RuntimeError: implement_array_function method already has a docstring"

I use PythonAnywhere to update a Twitter feed of COVID-19 statistics in my county. I recently made an update that uses matplotlib to construct some graphics. I tested on my own machine and it works great there, but I'm getting the below error here.

Traceback (most recent call last):
  File "/home/barowe/kingscoronavirustracker/kingscoronatracker.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "/usr/lib/python3.8/site-packages/matplotlib/__init__.py", line 138, in <module>
Traceback (most recent call last):
  File "/home/barowe/kingscoronavirustracker/kingscoronatracker.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "/usr/lib/python3.8/site-packages/matplotlib/__init__.py", line 138, in <module>
    from . import cbook, rcsetup
  File "/usr/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 31, in <module>
    import numpy as np
  File "/usr/lib/python3.8/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/usr/lib/python3.8/site-packages/numpy/core/__init__.py", line 17, in <module>
    from . import multiarray
  File "/usr/lib/python3.8/site-packages/numpy/core/multiarray.py", line 14, in <module>
    from . import overrides
  File "/usr/lib/python3.8/site-packages/numpy/core/overrides.py", line 16, in <module>
    add_docstring(
RuntimeError: implement_array_function method already has a docstring

[edited by admin: formatting]

this is an error that happens when numpy is imported twice- are you possibly importing numpy and then importing matplotlib? (where matplotlib itself is also importing numpy)

Hmm.... No, I don't have numpy imported on its own. Thanks for fixing the formatting on the code. These are my imports below:

import matplotlib.pyplot as plt
import requests
from bs4 import BeautifulSoup
import time
from pdf2image import convert_from_path
import tweepy

matplotlib.pyplot is importing numpy.

@glenn Yes. I see that, but I don't believe I have it imported twice as was suggested, unless I'm missing something else?

Are you running the program from the editor inside PythonAnywhere? If so, you might get into a situation where things work the first time you run it, but then if you run it again, you get that error. The workaround is to exit the console at the bottom of the page (using the exit() function) before running it.

@giles Looks like that worked! Thanks so much!

Excellent, thanks for confirming!