Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pywin32 ImportError for win32files on Windows7 #9751

Closed
wb8tyw opened this issue Oct 10, 2021 · 14 comments · Fixed by #9752
Closed

pywin32 ImportError for win32files on Windows7 #9751

wb8tyw opened this issue Oct 10, 2021 · 14 comments · Fixed by #9752

Comments

@wb8tyw
Copy link

wb8tyw commented Oct 10, 2021

I am trying to port the d-rats applications from python2 to python3, etc.

My test system is frozen at Windows 7 since Windows 10 is not supported by the hardware vendor.

I thought that msys2 mingw-64 would make the easiest deployment for end users for the python packages that are available, but have hit an issue with the mingw-w64-x86_64-python-pywin32 package.

$ python d_rats/dplatform.py
dPlatform  : Config dir: C:/Users/malmberg/AppData/Roaming/D-RATS-EV
dPlatform  : Default dir: C:/Users/malmberg/Desktop
dPlatform  : Log file (foo): C:/Users/malmberg/AppData/Roaming/D-RATS-EV/logs/foo.txt
Traceback (most recent call last):
  File "\\aviary\home\work\d-rats\D-Rats\d_rats\dplatform.py", line 787, in <module>
    do_test()
  File "\\aviary\home\work\d-rats\D-Rats\d_rats\dplatform.py", line 777, in do_test
    printlog("dPlatform", " : Serial ports: %s" % __pform.list_serial_ports())
  File "\\aviary\home\work\d-rats\D-Rats\d_rats\dplatform.py", line 617, in list_serial_ports
    import win32file # type: ignore
ImportError: DLL load failed while importing win32file: The specified module could not be found.

Any help would be appreciated.

OS is windows 7 64 bit.
msys2 was installed and packages were installed today.

@jeremyd2019
Copy link
Member

It actually only just got built/uploaded

@Biswa96
Copy link
Member

Biswa96 commented Oct 10, 2021

In Process Monitor, python can't find pywintypes39.dll. It lives under pywin32_system32 folder. Found similar issue mhammond/pywin32#1431

@lazka
Copy link
Member

lazka commented Oct 10, 2021

lazka added a commit to lazka/MINGW-packages that referenced this issue Oct 10, 2021
Disable it, so it takes the fallback path used for older Python
versions.

Fixes msys2#9751
@lazka
Copy link
Member

lazka commented Oct 10, 2021

See #9752

@raedrizqie
Copy link
Contributor

Chris, what does options=(staticlibs) in PKGBUILD do? Linking with static (gcc, stdc++ & winpthread)?

@Biswa96
Copy link
Member

Biswa96 commented Oct 11, 2021

From PKGBUILD(5) man page:

staticlibs: Leave static library (.a) files in packages. Specify !staticlibs to remove them (if they have a shared counterpart).

@raedrizqie
Copy link
Contributor

ah ok..

I built my pywin32 locally with -static-libgcc -static-libstdc++ -static -lwinpthread

I didn't put pywintypesXX.dll and pythoncomXX.dll in System32 folder. I never had import error like the one reported here.

@ZachBacon
Copy link
Contributor

ah ok..

I built my pywin32 locally with -static-libgcc -static-libstdc++ -static -lwinpthread

I didn't put pywintypesXX.dll and pythoncomXX.dll in System32 folder. I never had import error like the one reported here.

I'm glad you didn't put anything in the system32 folder, you should never put anything in the system32 folder in my opinion.

@raedrizqie
Copy link
Contributor

i think, the only way to fix pywin32 missing dll is to put pythoncom and pywintypes dll in %SYSTEM32% folder (like upstream does)

@ZachBacon
Copy link
Contributor

ZachBacon commented Mar 10, 2022 via email

@ZachBacon
Copy link
Contributor

ZachBacon commented Mar 10, 2022 via email

@ZachBacon
Copy link
Contributor

ZachBacon commented Mar 10, 2022 via email

@lazka
Copy link
Member

lazka commented Mar 10, 2022

We currently patch this here: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-python-pywin32/010-workaround-broken-add-dll-dir.patch

Because our Python doesn't support add_dll_directory() yet, see msys2-contrib/cpython-mingw#48

@MehdiChinoune
Copy link
Collaborator

Sorry, I found them under ${MINGW_PREFIX}/lib/python3.9/site-packages/pywin32_system32.
I think somehow I executed the wrong command to search for them.

$ pacman -Fx pythoncom39\.dll
mingw64/mingw-w64-x86_64-python-pywin32 302-5
    mingw64/lib/python3.9/site-packages/pywin32_system32/pythoncom39.dll
ucrt64/mingw-w64-ucrt-x86_64-python-pywin32 302-5 [installed]
    ucrt64/lib/python3.9/site-packages/pywin32_system32/pythoncom39.dll
clang64/mingw-w64-clang-x86_64-python-pywin32 302-5 [installed]
    clang64/lib/python3.9/site-packages/pywin32_system32/pythoncom39.dll
$ pacman -Fx pywintypes39\.dll
mingw64/mingw-w64-x86_64-python-pywin32 302-5
    mingw64/lib/python3.9/site-packages/pywin32_system32/pywintypes39.dll
ucrt64/mingw-w64-ucrt-x86_64-python-pywin32 302-5 [installed]
    ucrt64/lib/python3.9/site-packages/pywin32_system32/pywintypes39.dll
clang64/mingw-w64-clang-x86_64-python-pywin32 302-5 [installed]
    clang64/lib/python3.9/site-packages/pywin32_system32/pywintypes39.dll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants