Forums

Error

Hello All, Importing math function works in the console whereas importing pandas as pd shows the following error.

RuntimeError: implement_array_function method already has a docstring

I don't know what's happening. I am using python 3.7 Please help

hi there- just to confirm, if you start a brand new python3.7 console, and then do "import pandas as pd", do you see that error?

Nope, not in the new console. But when I try it on the console containing app.py it shows.

what is the console containing app.py? is it a python or a bash console? have you tried restarting it?

After hours of debugging, solved it. For what it's worth, the working directory is not /appname/mysite/ rather appname. The error log said it could not find the data file named "xyz.xlsx". Changed the path in the code and it works fine.

ah I see- definitely use the full/absolute path instead of a relative path to avoid this issue.

How did you solve the error?

use the full/absolute path instead of a relative path to avoid this issue.

Yes - should be a tips list on pythonanywhere somewhere like this:<br>

  • Ect.
  • Use full path not relative path
  • Ect.

That's all covered on our help pages. In general, searching for an error message on the help pages should give you a page that helps with it.

getting this same error just from importing pandas in flask_app.py

'import pandas as pd'

did any of you run into this issue?

What is the "same error"? There were different errors mentioned above.

Hey there,

I have the same problem, but I can't seem to fix it.
I changed all the paths to full paths in my code, but I still get the exact same error as OP.

Sorry for this stupid question, I'm new to this and followed conradho's dashingdemo on GitHub and implemented my own idea. It runs on locally on my Laptop but now here, on Pythonanywhere

There are a number of problems mentioned in this thread. Which one are you experiencing?

Hey glenn, thank you for answering.

I try to answer you as specific as possible:

Like I said I followed this tutorial.
When I run the flask_app.py I get this error:

Traceback (most recent call last):
  File "/home/FabiB93/mysite/flask_app.py", line 11, in <module>
    from dashing_demo_app import app
  File "/home/FabiB93/dashing_demo_app.py", line 4, in <module>
    import pandas as pd
  File "/usr/lib/python3.7/site-packages/pandas/__init__.py", line 11, in <module>
    __import__(dependency)
  File "/usr/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/usr/lib/python3.7/site-packages/numpy/core/__init__.py", line 17, in <module>
    from . import multiarray
  File "/usr/lib/python3.7/site-packages/numpy/core/multiarray.py", line 14, in <module>
    from . import overrides
  File "/usr/lib/python3.7/site-packages/numpy/core/overrides.py", line 47, in <module>
    """)
RuntimeError: implement_array_function method already has a docstring

I installed the modules as mentioned in the repo (virtualenv).

So far I already changed all the paths to absolute paths in both flask_app.py and dashing_demo_app.py.
I'm really new to this as a whole and really don't know if im stupid or not right now.

That error is not caused by path issues. The path stuff arose because of a different question in the thread.

The error that you are getting, appears to be an issue with running numpy under uwsgi (that is in a web app on PythonAnywhere) https://github.com/numpy/numpy/issues/14384 Unfortunately, the numpy project do not seem to have a fix for it. Since this appears to be a new issue with numpy, perhaps an older version of numpy will work better.

I downgraded to python 3.6 and saw this issue was resolved when refreshing the instance. hope that can help!

Cool. Thanks for the info.

So, I was running into this issue as well. This was with the Python 3.7 interpreter running numpy 1.18.1. I was running a script from the files view that imported os, tweepy and pandas that produced the "implement_array_function method already has a docstring error". I closed the file, reopened it...and all was well. I'm not sure why - my intent was to actually switch to the python 3.6 interpreter as suggested above.

run : import pandas as pd for 2 times in a console, the 1st is alright 2nd time: "implement_array_function method already has a docstring" so confusing.

As stated previously in the thread, that is an issue with the way that some versions of numpy load, so it cannot be imported twice in the same process.

If I remove 'import pandas as pd' for the next run (or 'import pickle' or any other import), then it says 'pd is not defined', if import it again, the mentioned error comes up. It makes the console barely usable.

hi, try to update numpy and pandas to their latest versions and see if it works. as far as i can guess, this error indicates that implement_array_function has a docstring (doc) and it is going to be redefined.

As previously stated in this thread: The issue is a new one that has not been fixed in the most recent numpy. Older versions of numpy may not suffer from the issue, but the newest version does.

change working directory and use full path. It resolved the error

I (or rather my students) have the same issue. Also when importing scipy (alone or, e.g., scipy.interpolate), besides numpy. No, it's not a problem of working directory and path. It's a bug inside the site-wide libraries which are included using full path. If you kill the console and restart a new one, the first "import numpy / scipy" won't give an error, but numpy resp.scipy won't be available. When you re-run the script which does the import, the error pops up.

I think there are a couple of different errors being talked about in this thread, but yes -- one of them is that numpy (and thus scipy) can't be imported twice into the same process. The fix for that one, as you say, is to kill the console before re-running a script, or (as Glenn suggested earlier) to downgrade numpy to an older version. Your suggestion is probably the best one, as older versions are not as good, and because downgrading numpy will use up extra disk space.