Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'RuntimeError: implement_array_function method already has a docstring' after matplotlib installation #15563

Closed
moelliDo opened this issue Feb 13, 2020 · 14 comments
Labels
32 - Installation Problems installing or compiling NumPy 57 - Close? Issues which may be closable unless discussion continued

Comments

@moelliDo
Copy link

I'm using numpy==1.18.1 within a conda environment. Everything worked fine until I installed matplotlib==3.1.3 yesterday. After matplotlib has been installed (successfully), and I try to import either matplotlib or numpy using

import numpy

or

import matplotlib

I get the following error:

Error message:

`Traceback (most recent call last):
File "C:\Users\user\AppData\Roaming\Python\Python36\site-
packages\IPython\core\interactiveshell.py", line 2963, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in
import matplotlib
File "C:\Program Files\JetBrains\PyCharm
2019.2.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\Users\user\Anaconda3\envs\ma-automl-ppm\lib\site-packages\matplotlib_init
.py", line 138, in
from . import cbook, rcsetup
File "C:\Program Files\JetBrains\PyCharm
2019.2.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\Users\user\Anaconda3\envs\ma-automl-ppm\lib\site-
packages\matplotlib\cbook_init
.py", line 31, in
import numpy as np
File "C:\Program Files\JetBrains\PyCharm
2019.2.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\Users\user\Anaconda3\envs\ma-automl-ppm\lib\site-packages\numpy_init
.py", line
142, in
from . import core
File "C:\Program Files\JetBrains\PyCharm
2019.2.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\Users\user\Anaconda3\envs\ma-automl-ppm\lib\site-packages\numpy\core_init
.py",
line 24, in
from . import multiarray
File "C:\Program Files\JetBrains\PyCharm
2019.2.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\user\Anaconda3\envs\ma-automl-ppm\lib\site-
packages\numpy\core\multiarray.py", line 14, in
from . import overrides
File "C:\Program Files\JetBrains\PyCharm
2019.2.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\user\Anaconda3\envs\ma-automl-ppm\lib\site-packages\numpy\core\overrides.py", line 47, in
""")
RuntimeError: implement_array_function method already has a docstring`

Numpy/Python version information:

'3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)]'

installed packages within the virtual environment:

absl-py 0.9.0 alembic 1.3.2 astor 0.8.1 autokeras 1.0.0 backcall 0.1.0 bleach 2.1.3 cachetools 4.0.0 certifi 2019.11.28 chardet 3.0.4 ciso8601 2.1.2 Click 7.0 colorama 0.3.9 cycler 0.10.0 dash 1.7.0 dash-bootstrap-components 0.7.2 dash-core-components 1.6.0 dash-daq 0.3.1 dash-html-components 1.0.2 dash-renderer 1.2.2 dash-table 4.5.1 decorator 4.3.0 dnspython 1.16.0 entrypoints 0.2.3 eventlet 0.25.1 Flask 1.1.1 Flask-Caching 1.8.0 Flask-Compress 1.4.0 Flask-Migrate 2.5.2 Flask-SocketIO 4.2.1 Flask-SQLAlchemy 2.4.1 future 0.18.2 gast 0.2.2 google-auth 1.11.0 google-auth-oauthlib 0.4.1 google-pasta 0.1.8 graphviz 0.13.2 greenlet 0.4.15 grpcio 1.26.0 h5py 2.10.0 html5lib 1.0.1 idna 2.8 intervaltree 3.0.2 ipykernel 4.8.2 ipython 6.4.0 ipython-genutils 0.2.0 ipywidgets 7.2.1 itsdangerous 1.1.0 jedi 0.12.0 Jinja2 2.10.3 joblib 0.14.1 jsonschema 2.6.0 jupyter 1.0.0 jupyter-client 5.2.3 jupyter-console 5.2.0 jupyter-core 4.4.0 Keras 2.3.1 Keras-Applications 1.0.8 Keras-Preprocessing 1.1.0 keras-tuner 1.0.1 kiwisolver 1.0.1 lightgbm 2.3.1 lxml 4.4.2 Mako 1.1.0 Markdown 3.1.1 MarkupSafe 1.0 matplotlib 3.1.3 mistune 0.8.3 mkl-fft 1.0.15 mkl-random 1.1.0 mkl-service 2.3.0 monotonic 1.5 mpmath 1.0.0 nbconvert 5.3.1 nbformat 4.4.0 networkx 2.4 nose 1.3.7 notebook 5.5.0 numpy 1.18.1 oauthlib 3.1.0 opt-einsum 3.1.0 opyenxes 0.3.0 ortools 7.4.7247 packaging 20.1 pandas 0.25.3 pandocfilters 1.4.2 parso 0.2.1 pickleshare 0.7.4 pip 19.3.1 plotly 4.4.1 pm4py 1.2.8 prompt-toolkit 1.0.15 protobuf 3.11.2 psutil 5.6.5 PuLP 2.0 pyarrow 0.15.1 pyasn1 0.4.8 pyasn1-modules 0.2.8 pydotplus 2.0.2 Pygments 2.4.2 pyparsing 2.2.0 python-dateutil 2.7.3 python-editor 1.0.4 python-engineio 3.10.0 python-socketio 4.4.0 pytz 2019.3 pyvis 0.1.7.0 pywinpty 0.5.3 PyYAML 5.3 pyzmq 17.0.0 qtconsole 4.3.1 requests 2.22.0 requests-oauthlib 1.3.0 retrying 1.3.3 rsa 4.0 scikit-learn 0.22.1 scipy 1.4.1 Send2Trash 1.5.0 setuptools 42.0.1.post20191125 simplegeneric 0.8.1 six 1.11.0 sklearn 0.0 sortedcontainers 2.1.0 SQLAlchemy 1.3.12 sympy 1.1.1 tabulate 0.8.6 tensorboard 2.0.2 tensorflow 2.0.0 tensorflow-estimator 2.0.1 termcolor 1.1.0 terminado 0.8.1 terminaltables 3.1.0 testpath 0.3.1 tornado 5.0.2 tqdm 4.41.1 traitlets 4.3.2 urllib3 1.25.7 wcwidth 0.1.7 webencodings 0.5.1 websockets 8.1 Werkzeug 0.16.0 wheel 0.33.6 widgetsnbextension 3.2.1 wincertstore 0.2 wrapt 1.11.2

@aemm2016
Copy link

aemm2016 commented Mar 9, 2020

Same problem here.. after upgrade python3 and reinstall necessary modules following occured suddenly.
import numpy.random File "/usr/local/lib/python3.6/dist-packages/numpy/__init__.py", line 142, in <module> from . import core File "/usr/local/lib/python3.6/dist-packages/numpy/core/__init__.py", line 24, in <module> from . import multiarray File "/usr/local/lib/python3.6/dist-packages/numpy/core/multiarray.py", line 14, in <module> from . import overrides File "/usr/local/lib/python3.6/dist-packages/numpy/core/overrides.py", line 47, in <module> """) RuntimeError: implement_array_function method already has a docstring

@mattip
Copy link
Member

mattip commented Mar 12, 2020

Does this happen outside pycharm (from a regular cmd command prompt, activate your conda environment then try to run your code)?

@mattip
Copy link
Member

mattip commented Mar 12, 2020

@aemm2016 note you seem to be on Linux, not windows. Are you also running from inside PyCharm?

@knutj
Copy link

knutj commented Mar 26, 2020

Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/knutjb/PycharmProjects/xray/xray3.py", line 1, in
import numpy as np
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/numpy/init.py", line 142, in
from . import core
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/numpy/core/init.py", line 24, in
from . import multiarray
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/numpy/core/multiarray.py", line 14, in
from . import overrides
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/numpy/core/overrides.py", line 16, in
add_docstring(
RuntimeError: implement_array_function method already has a docstring
import numpy as np
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/numpy/init.py", line 142, in
from . import core
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/numpy/core/init.py", line 24, in
from . import multiarray
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/numpy/core/multiarray.py", line 14, in
from . import overrides
File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/numpy/core/overrides.py", line 16, in
add_docstring(
RuntimeError: implement_array_function method already has a docstring

@mattip
Copy link
Member

mattip commented Mar 26, 2020

I see that PyCharm has a import hook:

File "/snap/pycharm-professional/192/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)

Is pydev something supplied with PyCharm or did you install it yourself?

@MrChenFeng
Copy link

have you tried conda install matplotlib
I tried many solution all failed. But the above updating helped me.
Besides, the problem only happens in pycharm console if I open python in bash there will be no problem.

@NMertsch
Copy link

@mattip PyDev is a part of PyCharm.

I have the same problem. From the terminal it runs perfectly fine, but with PyCharm it fails. #14384 seems to be related.

@anirudh2290
Copy link
Member

looks like #14012 may also be related.

@sakoht
Copy link

sakoht commented May 12, 2020

This is happening to me too, only in PyCharm. The problem went away after I rebuilt my virtualenv.

@Louagyd
Copy link

Louagyd commented May 18, 2020

you can simply just try matplotlib==3.0.3

@msarafzadeh
Copy link

this happened ever since I upgraded to pycharm 2020.1
the bug only occurs in debug mode

@rossbar
Copy link
Contributor

rossbar commented Jul 17, 2020

Is this issue still active or has it been resolved in PyDev/pycharm? Are the pycharm/pydev instructions in the troubleshooting guide relevant?

@rossbar rossbar added 32 - Installation Problems installing or compiling NumPy 57 - Close? Issues which may be closable unless discussion continued labels Jul 17, 2020
@seberg
Copy link
Member

seberg commented Jul 17, 2020

This was an "issue" with Numpy, it should be fixed by gh-16239, although importing NumPy twice works now more realiably, it can lead to errors, I have a PR which would add a warning when this happens. But I think you are right and we can close this.

@seberg seberg closed this as completed Jul 17, 2020
@anhzhi
Copy link

anhzhi commented Mar 8, 2021

This issue may occure when numpy/matplotlib or their requiment packages degraded, with their dependency broken and version requiments not met.

For example: install package of six to 1.5.6, which break the requirement six>=1.10 of matplotlib 2.2.5 .
Then this issue happens.

I found a solution that works in Pycharm.

  1. clean cache of numpy in pycharm which seems like C:\Users\anhzhi.PyCharm2019.3*numpy*
  2. remove pyc in Program Folder for JetBrains
  3. reinstall numpy/matplotlib and check their requiments strickly met.
  4. restart Pycharm and make sure numpy can import.

I think step 3 is key and make use, while step 1 and 2 explains why this issue not happens outside pycharm.
I use "Everything" to find those matched files in step 1 and step 2.

I wish my comment can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
32 - Installation Problems installing or compiling NumPy 57 - Close? Issues which may be closable unless discussion continued
Projects
None yet
Development

No branches or pull requests