Select to view content in your preferred language

python library versions error: numpy and matplotlib

711
1
11-08-2024 03:43 PM
AdamGallaher
New Contributor

Hello, 

I ran into an interesting error today when trying to run a script I wrote. The script uses arcpy, numpy, and scipy. There seems to be some error when running arcgis pro commands that leverage the numpy library. I attempted to troubleshoot by checking the versions of different basic libraries. Below are the outputs from that effort. Is anyone aware of a possible issue with a new update of ArcGIS Pro or arcpy? Has anyone encounter a similar issue and have a workaround or solution? Thank you in advance for your consideration. 

Adam  

import sys
print(sys.version)
3.11.10 (main, Sep 20 2024, 18:44:55) [MSC v.1938 64 bit (AMD64)]
import numpy
print(numpy.__version__)
2.1.3
import scipy
print(scipy.__version__)
1.14.1
import matplotlib

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.3 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last): File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\idlelib\run.py", line 165, in main
ret = method(*args, **kwargs)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\idlelib\run.py", line 579, in runcode
exec(code, self.locals)
File "<pyshell#15>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\colors.py", line 56, in <module>
from matplotlib import _api, _cm, cbook, scale
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\scale.py", line 22, in <module>
from matplotlib.ticker import (
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\transforms.py", line 49, in <module>
from matplotlib._path import (
AttributeError: _ARRAY_API not found
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
import matplotlib
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\colors.py", line 56, in <module>
from matplotlib import _api, _cm, cbook, scale
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\scale.py", line 22, in <module>
from matplotlib.ticker import (
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\matplotlib\transforms.py", line 49, in <module>
from matplotlib._path import (
ImportError: numpy.core.multiarray failed to import

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

Pro 3.4, installed today

 

sys.version
'3.11.10 (main, Sep 20 2024, 18:44:55) [MSC v.1938 64 bit (AMD64)]'

np.__version__
'1.24.3'

scipy.__version__
'1.9.3'

 

in the arcgispro-py3 environment

Addendum

You can install numpy 2.x into a arcgis pro environment since arcpy is compiled against the specified environment above.  

You will have to create a separate environment to do your numpy stuff separate from arcpy if that is your intent.  Also, you will find many things that you may need to fix in your current scripts

NumPy 2.0 migration guide — NumPy v2.1 Manual

 


... sort of retired...
0 Kudos