Select to view content in your preferred language

Anybody has luck with import arcpy in 10.5.1?

4874
18
10-13-2017 04:43 AM
RajuGopinath1
Emerging Contributor

The import arcpy doesn't work in 10.5.1 ArcGIS Desktop installation of python 2.7.13. Anybody in the same boat?

I have both ArcGIS Server and Desktop installed in this machine. But, default python is 32 bit one. The pth variables and environment variables are all good (as it works fine in a Desktop 10.3 installation with same configuration). I even run a repair on this installation. Nothing works.

Here is the error which I get on running import arcpy:

H:\>python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.executable
C:\Python27\ArcGIS10.5\python.exe
>>> import arcpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\__init__.py", line
 20, in <module>
    import numpy
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\__init__.py", line 187, i
n <module>
    from . import add_newdocs
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\add_newdocs.py", line 13,
 in <module>
    from numpy.lib import add_newdoc
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\lib\__init__.py", line 18
, in <module>
    from .polynomial import *
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\lib\polynomial.py", line
19, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\linalg\__init__.py", line
 51, in <module>
    from .linalg import *
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\linalg\linalg.py", line 2
9, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg
ImportError: DLL load failed: The specified path is invalid.
>>>

I initiated a tech support case with ESRI and they don't have anything new to contribute as they think that it's a bug. So, they transferred my case to Desktop team from where I am waiting for a response. Meanwhile, I thought of posting it in the community to see whether anybody has luck with solving this issue?

Tags (1)
0 Kudos
18 Replies
DanPatterson_Retired
MVP Emeritus

The best thing is to uninstall all versions of python and do a repair of ArcMap using Windows add/remove programs ... then select repair.  Python will be installed and it should now point to the correct version.  But you said that worked? was that after you removed all other versions of python?  also check to see if the modules in numpy.linalg ... lapack_lite, _umath_linalg ... actually exist... they are *.pyd files for both.  Barring that you will have to examine the Test folder there to see if you matching/installation is failing one of the tests

RajuGopinath1
Emerging Contributor

Dan- I don't have any other versions of python in that box where10.5.1 is installed. I mentioned that arcpy import is working in Desktop 10.3 version. So, something might be missing in 10.5.1. Regarding repair, I already repaired arcgis installation of python in 10.5.1 machine with no luck. Please see the screenshot of linalg folder- I have all those files in python folder.
If "import arcpy" is working on your ArcGIS Desktop 10.5.1/Python 2.7.13, do you mind uploading your numpy folder as a zip file?
We have 2 machines with 10.5.1 installed (one an upgrade from 10.3 and other a fresh install). But "import arcpy" is not working in either of them. I don't want to copy numpy from a 10.3 machine with 2.7.8 version of python.

0 Kudos
DanPatterson_Retired
MVP Emeritus

As indicated, two versions of python seem to being found.  If you want one version, all existing versions must be installed prior to repairing.

Copying portions of a numpy installation won't work if there are failures in the checks of the imports... In the case of importing numpy.linalg it is the __init__.py file that controls that.

You can try checking paths and registry edits, but clean installations usually work unless you have some weird hardware software configuration

0 Kudos
RajuGopinath1
Emerging Contributor

Dan- As indicated in my 2 previous comments, I don't have 2 versions of python in that box. OS is windows 2008 R2.

0 Kudos
DanPatterson_Retired
MVP Emeritus

I must be confused,  you said you have server and desktop installed on that machine, which suggested python is installed with each... worth a check because something isn't pointing to the right configuration

0 Kudos
HåkonDreyer
Esri Contributor

What happens if you try?

import numpy

print(numpy.linalg)

0 Kudos
RajuGopinath1
Emerging Contributor

I can't go past importing numpy.

H:\>python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\__init__.py", line 187, i
n <module>
    from . import add_newdocs
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\add_newdocs.py", line 13,
 in <module>
    from numpy.lib import add_newdoc
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\lib\__init__.py", line 18
, in <module>
    from .polynomial import *
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\lib\polynomial.py", line
19, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\linalg\__init__.py", line
 51, in <module>
    from .linalg import *
  File "C:\Python27\ArcGIS10.5\lib\site-packages\numpy\linalg\linalg.py", line 2
9, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg
ImportError: DLL load failed: The specified path is invalid.
>>>

0 Kudos
VinceAngelo
Esri Esteemed Contributor

If you have both Desktop and Server on your machine, you must have two copies of Python (32-bit and 64-bit).  If you had an old version of Python with the 10.3.1 install, then you might have as many as three installs (four, if Server or 64-bit Background Geoprocessing was installed).

import arcpy works on every one of my 10.5.1 installs (both 32-bit and 64-bit, since I install Desktop 64-bit Background Geoprocessing), so the problem is specific to your installation.

You should make sure the appropriate bin or bin64 folder is in your PATH variable (different install order with default PATH will cause all manner of install issues -- If Windows finds the right DLL name, but it's the incorrect word size, it will report "File Not Found").

RajuGopinath1
Emerging Contributor

What does your PATH variable look like? Basically,I have the same config in 10.3.1 production machine. The config which worked in 10.3.1 didn't work in 10.5.1- that's where I am confused.

0 Kudos