Error: ImportError: DLL load failed: %1 is not a valid Win32 application
When attempting to import ArcPy into ArcGIS Pro, the import statement returns the following error message:
Error: ImportError: DLL load failed: %1 is not a valid Win32 application.
ArcGIS Pro's 64-bit Python interpreter is attempting to import a 32-bit module, as the Environment Variable 'PYTHON' or 'PYTHONPATH' is referencing a folder containing ArcMap's 32-bit ArcPy module.
Solution or Workaround
- Run the following script in the Python interpreter in ArcGIS Pro:
import sys for path in sys.path: print (path)
Note: The script loops through each path the Python interpreter references for modules. If the generated lists include the ArcMap's 32-bit ArcPy module, move to step 2.
- Navigate to Control Panel > System > Advanced system settings > Environment Variables. The Environment Variables 'PYTHON' or 'PYTHONPATH' is defined here.
- Edit the 'PYTHON' or 'PYTHONPATH' variable and remove all references to the ArcMap 32-bit installation of Python.
- Restart the machine.
- Esri Canada: Configure your Python IDE to work with ArcMap and ArcGIS Pro's ArcPy
- Problem: Unable to import arcpy
- FAQ: Why do Python scripts fail on a machine with both ArcGIS for Server and Desktop installed?