ImportError: No module named win32con

4238
7
Jump to solution
03-20-2018 06:36 AM
JaredPilbeam2
MVP Regular Contributor

I updated from ArcMap 10.4 to 10.5 and now Pythonwin is not opening. Here is the full error message:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "pywin\framework\startup.py", line 49, in <module>
    __import__(moduleName)
  File "C:\Python27\ArcGIS10.4\Lib\site-packages\pythonwin\pywin\framework\intpyapp.py", line 3, in <module>
    import win32con
ImportError: No module named win32con

It's looks as though it is because it's still rooted in the ArcGIS 10.4 folder. What is the best way to fix this?

0 Kudos
1 Solution

Accepted Solutions
JimmyKroon
Occasional Contributor II

I had this same problem today after upgrading from 10.4 to 10.5. I'm not sure Dan understood that the error message occurs when opening PythonWin itself - probably caused by PythonWin looking for ArcGIS 10.4 components that are no longer installed.

I fixed this by reinstalling PythonWin from here. You most likely want the win32-py27 version.

Releases · mhammond/pywin32 · GitHub 

View solution in original post

7 Replies
DanPatterson_Retired
MVP Esteemed Contributor

.....Python27\ArcGIS10.4\Lib\site-packages\pythonwin\pywin\framework\intpyapp.py",

What is running you access to pythonwin?  I just used to use pythonwin.exe in my shortcut

DanPatterson_Retired
MVP Esteemed Contributor

Also, I think it is win32com not n

JimmyKroon
Occasional Contributor II

I had this same problem today after upgrading from 10.4 to 10.5. I'm not sure Dan understood that the error message occurs when opening PythonWin itself - probably caused by PythonWin looking for ArcGIS 10.4 components that are no longer installed.

I fixed this by reinstalling PythonWin from here. You most likely want the win32-py27 version.

Releases · mhammond/pywin32 · GitHub 

View solution in original post

JaredPilbeam2
MVP Regular Contributor

Jimmy,

Thanks for the info. Did you install in your ArcGIS 10.5 folder?

I did download the win32-py27 version as ArcMap requires Python 2.7. It saved to my 10.5 folder: C:\Python27\ArcGIS10.5. I got this Setup message and then finished the install. I'm not sure what this message meant. I opened Pywin and tried a few of my scripts. There were errors for all of them. It won't even import the Arcpy module, or any module for that matter. It seems as though it doesn't know where to find them.

I uninstalled then reinstalled Pywin, but the same message appears. Have any idea what I'm doing wrong?

0 Kudos
JaredPilbeam2
MVP Regular Contributor

Update:

I uninstalled ArcMap 10.5.1 then reinstalled. Might not have been necessary but it made sure i started fresh. I also deleted any folders referring to older versions of ArcMap.

This is where I then installed the version of PythonWin you pointed out: C:\Python27\ArcGIS10.5\Lib\site-packages

The pywin32-223.win32-py2.7.exe version is compatible with Python IDLE 2.7.13, which is the version that is installed with ArcGIS 10.5.1. After the install the PythonWin application lives here: C:\Python27\ArcGIS10.5\Lib\site-packages\pythonwin\Pythonwin.exe

 

I think before I was simply not installing it in the correct location.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Jared... from my initial post

....Python27\ArcGIS10.4\Lib\site-packages\pythonwin\pywin\framework\intpyapp.py",  (note the path)

you will see where that intpyapp.py file should reside.

The only thing that changes per version is the drive  ie C and the arcmap version ArcGIS10.x

That is why your initial installation wasn't working

0 Kudos
JaredPilbeam2
MVP Regular Contributor

Thanks Dan,

I see what you mean now. To run the program, I was using a shortcut of the Pythonwin.exe out of the 10.4 folder, I believe. That's what I'm doing now out of the 10.5 folder.

In short, using a separate install of Python to run scripts that call the arcpy module will give you problems.

0 Kudos