Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Error importing matplotlib and numpy
-
Hello. I recently installed Pythonista on my iPad Pro, but have encountered an issue when trying to import NumPy. I actually just attempted the example script ‘3D Plot Demo.py’, but I get this message:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/E5F40FC6-6D13-4D26-8627-942D23047814/Pythonista3/Documents/site-packages/numpy/init.py", line 126, in <module>
from numpy.config import show as show_config
ImportError: No module named 'numpy.config'During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/E5F40FC6-6D13-4D26-8627-942D23047814/Pythonista3/Documents/Examples/Plotting/3D Plot Demo.py", line 2, in <module>
from mpl_toolkits.mplot3d import Axes3D
File "/var/containers/Bundle/Application/7723BAF5-917E-4356-BF47-4070B0CD0860/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/mpl_toolkits/mplot3d/init.py", line 6, in <module>
from .axes3d import Axes3D
File "/var/containers/Bundle/Application/7723BAF5-917E-4356-BF47-4070B0CD0860/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 22, in <module>
import matplotlib.axes as maxes
File "/var/containers/Bundle/Application/7723BAF5-917E-4356-BF47-4070B0CD0860/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/matplotlib/init.py", line 181, in <module>
from matplotlib.cbook import is_string_like
File "/var/containers/Bundle/Application/7723BAF5-917E-4356-BF47-4070B0CD0860/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/matplotlib/cbook.py", line 34, in <module>
import numpy as np
File "/private/var/mobile/Containers/Shared/AppGroup/E5F40FC6-6D13-4D26-8627-942D23047814/Pythonista3/Documents/site-packages/numpy/init.py", line 131, in <module>
raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.I would really appreciate some help with this, as it seems like a bug! I tried doing what was suggested above, which is to run a program from a different directory, but it doesn’t seem to matter. I also seem to be having this problem with matplotlib.
-
It seems that you have a copy of
numpy
inside yoursite-packages
folder. Pythonista comes withnumpy
preinstalled, so you should not install it manually intosite-packages
. (In fact, you can't, becausenumpy
uses compiled code.) Try deleting thenumpy
folder from yoursite-packages
, restart Pythonista, and see if you canimport numpy
now. -
That solved the problem. Thanks a bunch!