I have ArcGIS 10.0 And installed pythonwin 2.6.5
When wrote a script in Python Shell - it works just fine But in pythonwin - i get import arcpy error as below
>>> import arcpy
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named arcpy
-
1It looks like pythonwin cannot find the Arcpy module. Did you check if the path to arcpy is specified in pythonwin? I had a similar problem with anaconda and it was fixed by adding a path to arcpy.yanes– yanes2015年11月03日 16:24:36 +00:00Commented Nov 3, 2015 at 16:24
1 Answer 1
You need to make sure pythonwin knows where the ArcGIS python packages reside. A simple way to do this would be to create a text file called arcgis.pth (or anything you want with ".pth" as the extension) in the Lib\site-packages directory of your pythonwin installation. The contents of the file should be these 3 lines (modified as needed to reflect the paths of your ArcGIS installation):
C:\Program Files (x86)\ArcGIS\Desktop10.0\bin
C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy
C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Scripts
Once that file is in place, pythonwin should be able to access arcpy
successfully.
(Note that I wrote this based on my own ArcGIS 10.2 installation. I believe the directory structure was the same for 10.0, but if anybody can confirm this, that would be helpful.)
Explore related questions
See similar questions with these tags.