I am trying to build python scripts in Pycharm to run in ArcGIS background processing ArcGISx6410.5. When I run a script which includes "import arcpy" I get the following Error message:
Traceback (most recent call last):
File "D:/WWF - Sustainable Hydropower/FRA/Code/f1_zonal_stats.py", line 8, in <module>
import arcpy
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\__init__.py", line 22, in <module>
from arcpy.geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
ImportError: DLL load failed: %1 is not a valid Win32 application.
Could anyone help me to notice and solve this problem? I am the beginner user of Pycharm so it would be good if anyone could give me the steps on more details
Background Geoprocessing (64-bit)—Help | ArcGIS for Desktop
I would check to make sure pycharm is running the correct version of python which might be installed in assuming the 64 bit version was installed in that path.
c:\Python27\ArcGISx6410.5\python.exe
You can check for the running version of python... This example is for ArcGIS Pro nor ArcMap's version,
import sys
sys.executable
'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\pythonw.exe'
Line 4 is the result for Pro, which you should be using if you really need true 64 bit capabilities
This is the result of the running version of python on my code
import sys
sys.executable
'C:\\Python27\\ArcGISx6410.5\\pythonw.exe'
For the project interpreter in Pycharm, I set the path to the python.exe on Python27\ArcGISx6410.5
I also checked the sys.path and it seems no problem
sys.path
['C:\\Program Files\\JetBrains\\PyCharm Community Edition 2018.3.4\\helpers\\pydev', 'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2018.3.4\\helpers\\third_party\\thriftpy', 'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2018.3.4\\helpers\\pydev', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\ArcGISx6410.5\\DLLs', 'C:\\Python27\\ArcGISx6410.5\\lib', 'C:\\Python27\\ArcGISx6410.5\\lib\\plat-win', 'C:\\Python27\\ArcGISx6410.5\\lib\\lib-tk', 'C:\\Python27\\ArcGISx6410.5', 'C:\\Users\\User\\AppData\\Roaming\\Python\\Python27\\site-packages', 'C:\\Python27\\ArcGISx6410.5\\lib\\site-packages', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.5\\bin', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.5\\ArcPy', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.5\\ArcToolBox\\Scripts', 'D:\\WWF - Sustainable Hydropower\\FRA\\Code', 'D:/WWF - Sustainable Hydropower/FRA/Code']
I will have to pass you off to...
Configure your Python IDE to work with ArcMap and ArcGIS Pro’s Arcpy
which has some instructions that may be better.
I use ArcGIS Pro exclusively now and my python IDE is
I have passed this problem and already got the solution. Thanks for your help, anyway
So what was your solution? I just installed PyCharm, but have not yet hooked it up to ArcGIS Pro.
Stephen,
1. Open PyCharm and navigate to File/Settings/Project:{a_project_name_or_Deafult}/Project Interpreter...
2. If the Project Interpreter is blank, click the gear icon next to the blank box to Add...
3. Point it to your local ArcGIS Pro installed Python location, most likely
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe
(Tip: you can see the ArcGIS Pro Python 3 installation location by opening the Python Command Prompt under Windows/Start/ArcGIS)
Another place to configure this is under
1. Run/Edit Configuration...
2. Under Python/Environment there is a box for Python Interpreter.
3. If it is not set you can add it there.
Once this is set you have both arcpy and conda (for working with ArcGIS Python API) available in PyCharm.
#arcpy #pycharm