edit: I have 10.5 installed, please change the paths below to the correct version that you are using
Yes it is possible. PythonWin uses a windows installer which checks your registry and installs the package in your specified Python2.7 location - Currently it seems yours is at 'C:\Python27\python.exe' and it should be 'C:\Python27\ArcGIS10.5\python.exe' instead.
First, uninstall PythonWin because its using the wrong registry value, we will reinstall it in a minute.
Then save this script as 'C:\Python27\ArcGIS10.5\reg.py':
import sys
from _winreg import *
version = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
)
def RegisterPy():
try:
reg = OpenKey(HKEY_CURRENT_USER, regpath)
except EnvironmentError as e:
try:
reg = CreateKey(HKEY_CURRENT_USER, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg)
except:
print "*** Unable to register!"
return
print "--- Python", version, "is now registered!"
return
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
CloseKey(reg)
print "=== Python", version, "is already registered!"
return
CloseKey(reg)
print "*** Unable to register!"
print "*** You probably have another Python installation!"
if __name__ == "__main__":
RegisterPy()
Then from a cmd prompt run: C:\> C:\Python27\ArcGIS10.5\python.exe reg.py
You should see a message '---Python 2.7 is now registered!'
To verify its the right version, from the cmd prompt run 'C:> python'
Then within the interpreter run
import sys
print sys.executable
and it should return 'C:\\Python27\\ArcGIS10.5\\python.exe'
If this is the path, you should now be able to reinstall PythonWin and verify in the install wizard that it is now pointing to 'C:\\Python27\\ArcGIS10.5\\python.exe' then you should be good to go!