Access violation in Python 3.9
See original GitHub issueHello, To be quite honest, I’m not sure whether to report it here or on comtypes GitHub page, as I’m not that familiar with either of the repositories, and importing comtypes by itself works just fine.
Expected Behavior
Importing pywinauto works without issues
Actual Behavior
Importing pywinauto causes access violation issues on Windows
Steps to Reproduce the Problem
- Install Python 3.9
- Install pywinauto
- Import pywinauto in your script
Short Example of Code to Demonstrate the Problem
import faulthandler
import pywinauto
faulthandler.enable()
which then results in the following:
Windows fatal exception: code 0x80010108
Thread 0x00002358 (most recent call first):
File "C:\Python39\lib\site-packages\comtypes\__init__.py", line 180 in _shutdown
Windows fatal exception: code 0x80010108
Thread 0x00002358 (most recent call first):
File "C:\Python39\lib\site-packages\comtypes\__init__.py", line 180 in _shutdown
Specifications
- Pywinauto version: 0.6.8
- Python version and bitness: 3.9.5 x64
- Platform and OS: Win 10x64
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Windows fatal exception: access violation - Python Help
I'm using python 3.9.5 and I'm packing my app using pyarmor + pyinstaller. I've been using these tools for a very long time...
Read more >When using Yolov5 and Python 3.9.7 I get "Process finished ...
I have tried all of the answers that reference "exit code -1073741819 (0xC0000005)" (Which means access violation) but none of them work.
Read more >Access Violation python39.dll - Delphi-PRAXiS [en]
I'm using Delphi 10.4.2 and Python4Delphi with Python 3.9.2 Win64. I have the error "Access Violation at address in module python39.dll".
Read more >Problem plotting PlotShape - Neuron.yale.edu
_data)) OSError: exception: access violation reading ... I am running Python 3.9.4 with NEURON 8.0 installed via pip on Windows 10.
Read more >Error when viewing GeoDataFrame in GeoPandas: "OSError
...with Python 3.9, GDAL 3.4.3, Fiona 1.8.21, Geopandas 0.10.2 in a Conda environment (and finally I used PostGIS to do what I wanted...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For the time being, I thought of a workaround of just
atexit.unregister(comtypes._shutdown)
. How unsafe is it?Oh, wait!
comtypes
calls onlyatexit.register(_shutdown)
whileatexit.unregister(_shutdown)
fixes the problem. So in fact we unregister correct handler which fails. Still not good.