Third party modules incompatible with Python 3.12

I had to reinstall 3.10 to have both docx2txt and win32api run in the same script.
With 3,12, with some PYTHONPATH tweaking, you can have either one or the other, not both.
I hope that doc2txt will upgrade to the new Python version.

First, in order for anyone to diagnose a problem like this, we would need a properly detailed report.

What steps do you take, starting from a fresh Python 3.12, in order to reproduce the problem? In particular, exactly what “PYTHONPATH tweaking” are you doing, and why? What do you have in the PYTHONPATH to make docx2txt work, and what do you have in order to make win32api work?

What actual problem do you encounter if you try to use both at once?


But more importantly - why should we be able to help with the issue here? As you say, the projects are third-party, and I don’t think the developer of docx2txt posts here. Aside from that, it looks like docx2txt hasn’t been released since the middle of 2019, so of course it isn’t getting tested on the most recent Python versions.

Have you tried checking the project’s issue tracker to see if anyone has reported a similar problem? Or reporting it yourself?

1 Like

Thank you for your quick reply and advice.

As it happened, I wasn’t actually looking for help, since I already had solved my third-party incompatibility problems. I just uninstalled Python 3.12, which I didn’t really need, to go back to 3.10. I just thought that other developers with similar problems might appreciate my post. Naturally, I will forward it to the docx team, as you suggested.

This works as is on 3.10 (Windows 10+):
def onPrinter(self, event=None):
import tempfile
import win32api
from win32 import win32print # pip install pywin32 first
from win32api import ShellExecute
[…]

but it won’t work on 3.12 unless you put this on top in PYTONPATH:
C:\Users\Your_Name\AppData\Local\Programs\Python\Python310\Lib\site-packages\

A frequent problem with third-party modules is that a lot of them are no longer up to snuff after a few Python releases, so, tweaking PYTHONPATH may be the only way to go. Maybe another tweak could make 3.12 work with docx, I didn’t try all the possibilities.

But what is the interest of developing software that will run correctly on just one lone computer? Well, it’s a not-so-well-kept secret that with PyInstaller and the likes, it’s easy to freeze a standalone that will run on any computer without the Python interpreter.

My project is a freely redistributable GUI frontend for a text search toolkit. It uses other third-party modules, for instance Matt Chaput’s (orphaned) Whoosh 2.7.4 indexer/browser, whose output feeds a Keyword In Context (KWIC) display. It’s a small miracle that, jumping from one Python distro to the next one, I find a pythonic way (well, most of the time) to have a whole bunch of third-party libraries working together in a useful way. By the way, I will soon be looking for a suitable forum or repository to publish my stuff. Any suggestion is welcome.

This is not recommended and you attempt it at your own risk.

This means to tell Python 3.12 to try to use the package that you already installed for Python 3.10, as organized and installed there. This could fail in all sorts of ways. If Python 3.12’s Pip failed to install the package separately for the Python 3.12 installation, there’s probably a good reason for that.