pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

ImportError: No system module 'pywintypes' (pywintypes36.dll)

Open ghost opened this issue 8 years ago • 5 comments

I downloaded and "pip install"-ed pywin32 from http://www.lfd.uci.edu/~gohlke/pythonlibs/f9r7rmd8/pywin32-220.1-cp36-cp36m-win32.whl, as PyPI does not seem to serve a precompiled version compatible with Python 3.6.

Now, I am facing the following import error:

>>> import pywintypes
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\mek\AppData\Local\Programs\Python\Python36-32\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "C:\Users\mek\AppData\Local\Programs\Python\Python36-32\lib\site-packages\win32\lib\pywintypes.py", line 98, in __import_pywin32_system_module__
    raise ImportError("No system module '%s' (%s)" % (modname, filename))
ImportError: No system module 'pywintypes' (pywintypes36.dll)

In fact, as Process Monitor shows, the corresponding storage location "C:\Users\mek\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\pywin32_system32" is not even scanned by python.exe. Instead, many search paths ending with "/" show up.

[... (a lot of entries from %PATH%) ...]
12:37:26.9899610	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\pywintypes36.dll	NAME NOT FOUND	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open Reparse Point, Attributes: N, ShareMode: None, AllocationSize: n/a
12:37:26.9900549	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\win32\lib\pywintypes36.dll	NAME NOT FOUND	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open Reparse Point, Attributes: N, ShareMode: None, AllocationSize: n/a
12:37:26.9905114	python.exe	7368	CreateFile	C:\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9906117	python.exe	7368	CreateFile	C:\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9906786	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\python36.zip\<stdin>	PATH NOT FOUND	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9907763	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\DLLs\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9909128	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\Lib\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9909895	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9910751	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9911617	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\win32\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9912590	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\win32\lib\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
12:37:26.9913468	python.exe	7368	CreateFile	C:\Users\mek\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\pythonwin\<stdin>	NAME INVALID	Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a

Reported by: kunomeyer

Original Ticket: pywin32/bugs/740

ghost avatar Jan 03 '17 11:01 ghost

When looking at the PyPI-counterpart of https://github.com/pywin32/pypiwin32/blob/master/pywin32.pth, the following two lines are missing:


import os;os.environ["PATH"]+=(';'+os.path.join(sitedir,"pywin32_system32"))

This looks quite hacky to me (Python code in a text file, references to a non-declared sitedir variable), but this get things working.

(The background is that _win32sysloader.LoadModule(filename) actually uses LoadLibrary() under the hood. I have no idea about the origin of the postfixes, though.)

Original comment by: kunomeyer

ghost avatar Jan 03 '17 17:01 ghost

I'm working with the pypiwin32 group to have a compiled version up soon. I don't think it will be too long.

Original comment by: xaav

ghost avatar Jan 03 '17 19:01 ghost

[#721] is also somewhat related to this bug.

Original comment by: kunomeyer

ghost avatar Jan 04 '17 07:01 ghost

When looking at the PyPI-counterpart of https://github.com/pywin32/pypiwin32/blob/master/pywin32.pth, the following two lines are missing:


import os;os.environ["PATH"]+=(';'+os.path.join(sitedir,"pywin32_system32"))

This looks quite hacky to me (Python code in a text file, references to a non-declared sitedir variable), but this get things working.

(The background is that _win32sysloader.LoadModule(filename) actually uses LoadLibrary() under the hood. I have no idea about the origin of the postfixes, though.)

Original comment by: kunomeyer

pragyan-srivastava avatar Jul 09 '20 15:07 pragyan-srivastava

It import pywin32_bootstrap which does roughly the same thing, but with more functionality/complexity, depending how you look at it :)

mhammond avatar Jul 09 '20 22:07 mhammond

@pragyan-srivastava @dauletra

Since 71afa71e11e6631be611ca5cb57cda526b5e91ab, the PATH is now prepended, rather than appended. For Python >= 3.8, the PATH environment variable isn't even used. This is included in pywin32==226.

Python 3.7 has also reached EOL (meaning no security fixes/support) and I'd recommend migrating over to 3.8+ (see #2207)

.exe installers are now deprecated #1939, so you should install from PyPI (ie: pip install pywin32>=226)

Given the sheer amount of installation issue duplication and old history, I'd like to consolidate the current state of these issues. So I'll close and reference back any issue that only has comments showing the issue:

  • from before November 10th, 2019 (pywin32<226)
  • using .exe installers
  • using Python < 3.8

Please also try https://github.com/mhammond/pywin32#troubleshooting before opening a new issue, or let us, and others, know if it did resolve your issue.

Closing as duplicate of #721 and https://github.com/mhammond/pywin32/issues/1399

If you're having this issue with Jupyter Notebooks, refer to https://github.com/mhammond/pywin32/issues/1409 instead. If you're having this issue using the Microsoft Store distribution of Python, refer to https://github.com/mhammond/pywin32/issues/1383 instead. If you're having this issue with the Anaconda distribution of Python, refer to https://github.com/mhammond/pywin32/issues/1865 instead.

Avasam avatar Mar 26 '24 03:03 Avasam