I can't import pywinauto
on XP.
I have a computer running window 7 and a VM running XP. Both of these have almost identical versions of Python.
Here is a picture of differences between the Python27 folders in each environment: https://i.sstatic.net/ao4R7.png
It seems that these are inconsequential differences, especially when it comes to the package in question.
If I try to import pywinauto
on the XP VM I get the following:
>>> import pywinauto.controls
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pywinauto\__init__.py", line 28, in <module>
import findwindows
File "C:\Python27\lib\site-packages\pywinauto\findwindows.py", line 37, in <module>
import controls
File "C:\Python27\lib\site-packages\pywinauto\controls\__init__.py", line 33,in <module>
import win32_controls
File "C:\Python27\lib\site-packages\pywinauto\controls\win32_controls.py", line 31, in <module>
from pywinauto import win32functions
ImportError: cannot import name win32functions
>>>
I have not tried to re-install pywinauto
or pywin32
. Before I try that, I just want to know if there are any issues with pywinauto between XP and 7? Or between native windows and a VM?
Okay, I think I figured it out, although I have no idea why. My question was what I though was the root cause of my original problem which was that I got
sre_constants.error nothing to repeat
when I tried to compile my program in the XP virtual environment. The cause of this was in C:\Python27\Lib\site-packages\pywinauto\tests\asianhotkey.py
at line 110.
_asianHotkeyRE = re.compile (r"""
\(&.\) # the hotkey
(
(\t.*)| # tab, and then anything
#(\\t.*)| # escaped tab, and then anything
(\(.*\) # anything in brackets
)|
\s*| # any whitespace
:| # colon
(\.\.\.)| # elipsis
>| # greater than sign
<| # less than sign
(\n.*) # newline, and then anything
\s)*$""", re.VERBOSE)
I couldn't even run this in its own script in my virtual XP environment. It would run if I either removed the *
in either one of these lines
\s*| # any whitespace
or
\s)*$""", re.VERBOSE)
I have no idea why that was the case, just experimental outcomes.
Anyway, as far as I could tell the variable _asianHotkeyRE
is only used once in this whole package; at line (133) of this same file:
found = _asianHotkeyRE.search(text)
So I changed those two groups of code to
pattern = r"""
\(&.\) # the hotkey
(
(\t.*)| # tab, and then anything
#(\\t.*)| # escaped tab, and then anything
(\(.*\) # anything in brackets
)|
\s*| # any whitespace
:| # colon
(\.\.\.)| # elipsis
>| # greater than sign
<| # less than sign
(\n.*) # newline, and then anything
\s)*$"""
and
found = re.search(pattern,text)
Something about using regular expression compiling didn't like the formatting of this pattern. Maybe the version of re
that is installed on that virtual machine isn't up to date or something?
So long story short, it's fixed. I don't know why and I would love it if someone could try to reproduce the issue using their own virtual environments of any kind.