cannot get pythonwin working with ArcGIS 10.6.1

2016
17
11-21-2019 11:29 AM
RickHawkins
New Contributor II

I am using ArcMap 10.6.1 and am trying to install and use pythonwin but i am not having much luck. What version of pythonwin should i be using and what version of python? When i try to enter import arcpy i get an error saying that module does not work. I am using pywin32-217.win32-py2.7.exe. 

If i did not provide enough information please let me know. I just started learning python scripting for ArcGIS

0 Kudos
17 Replies
DanPatterson_Retired
MVP Emeritus

Find and check the site-packages folder in that path and look for numpy.  If it was installed, it should be there

0 Kudos
RickHawkins
New Contributor II

I have the following: C:\Python27\ArcGIS10.6\Lib\site-packages\numpy. It is installed so why do i get the error?

By the way, thanks for all of the help

0 Kudos
DanPatterson_Retired
MVP Emeritus

Rick....

Going totally image now... there is a common 'path' for spyder and for numpy

Try this

numpy will be in  …\Lib\site-packages\numpy

pythonwin is in as shown

0 Kudos
RandyBurton
MVP Alum

I'm wondering if you installed a second version of Python when you installed pythonwin.  Its been some time, but I seem to recall a prompt from pythonwin at install time asking about using existing Python or a new install.  From your traceback image above, I see the path 'C:\Python27\Lib\site-packages\pythonwin.....' which I don't think should be.

In your pythonwin Interactive Window, try the following and share the printout:

>>> import sys
>>> sys.path
['C:\\', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\ArcGIS10.6\\DLLs', 'C:\\Python27\\ArcGIS10.6\\lib', 'C:\\Python27\\ArcGIS10.6\\lib\\plat-win', 'C:\\Python27\\ArcGIS10.6\\lib\\lib-tk', 'C:\\Python27\\ArcGIS10.6\\Lib\\site-packages\\Pythonwin', 'C:\\Python27\\ArcGIS10.6', 'C:\\Python27\\ArcGIS10.6\\lib\\site-packages', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.6\\bin', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.6\\ArcPy', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.6\\ArcToolBox\\Scripts', 'C:\\Python27\\ArcGIS10.6\\lib\\site-packages\\win32', 'C:\\Python27\\ArcGIS10.6\\lib\\site-packages\\win32\\lib']
>>> sys.executable
'C:\\Python27\\ArcGIS10.6\\Lib\\site-packages\\Pythonwin\\Pythonwin.exe'
>>> import os
>>> os.listdir(r'C:\Python27')
['ArcGIS10.6']
>>> os.listdir(r'C:\Python27\ArcGIS10.6')
['DLLs', 'Doc', 'include', 'Lib', 'libs', 'LICENSE.txt', 'NEWS.txt', 'python.exe', 'pythonw.exe', 'pywin32-wininst.log', 'README.txt', 'Removepywin32.exe', 'Scripts', 'tcl', 'Tools', 'w9xpopen.exe']

#  I've included my output above as a sample of what you might see.
#  The specific python commands to enter, in order, are:

import sys
sys.path
sys.executable
import os
os.listdir(r'C:\Python27')
os.listdir(r'C:\Python27\ArcGIS10.6')‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
RickHawkins
New Contributor II

i uninstalled python, reinstalled arcgis desktop, reinstalled python and pythwin and this is what get:

sorry. not sure how to make the text bigger

0 Kudos
RickHawkins
New Contributor II

After making the edits and run this simple program:

I get the following errors:

not sure why the program is not running

0 Kudos
RandyBurton
MVP Alum

Outside of ArcMap, I don't think "Current" will work as a map document.  Try using a full path/filename to your map document in line 5.

Except for this error, it appears that you have Pythonwin working, correct?

RickHawkins
New Contributor II

when i run the script inside of ArcGIS everything works fine.

0 Kudos