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

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

Closed
ghost opened this issue Jan 3, 2017 · 6 comments
Closed

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

ghost opened this issue Jan 3, 2017 · 6 comments

Comments

@ghost
Copy link

ghost commented Jan 3, 2017

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
Copy link
Author

ghost commented Jan 3, 2017

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
Copy link
Author

ghost commented Jan 3, 2017

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
Copy link
Author

ghost commented Jan 4, 2017

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

Original comment by: kunomeyer

@ghost ghost assigned ghost and unassigned ghost Oct 24, 2017
@pragyan-srivastava
Copy link

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

@mhammond
Copy link
Owner

mhammond commented Jul 9, 2020

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

@Avasam
Copy link
Collaborator

Avasam commented Mar 26, 2024

@pragyan-srivastava @dauletra

Since 71afa71, 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 #1399

If you're having this issue with Jupyter Notebooks, refer to #1409 instead.
If you're having this issue using the Microsoft Store distribution of Python, refer to #1383 instead.
If you're having this issue with the Anaconda distribution of Python, refer to #1865 instead.

@Avasam Avasam closed this as completed Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants