Why is the PATH changed when Windows PyQt5 is imported?
Barry Scott
barry at barrys-emacs.org
Sun Jan 3 15:06:12 GMT 2021
I'm debugging an issue that is breaking some of my code.
I'm using Python 3.8 and PyQt5==5.12.2
What I'm seeing is that the PATH is changed by PyQt5 __init__.py.
It has this code in it:
---
import os as _os
_path = _os.path.dirname(__file__) + '\\Qt\\bin;' + _os.environ['PATH']
_os.environ['PATH'] = _path
---
Why is this necessary?
Its has the effect that any subprocess created from a PyQt5 program
gets this PATH.
And if a program that uses a different version of PyQt5 then the
one the PATH has at its start sees DLL errors.
Is this a because of the change in 3.8 for DLL loading?
Should this code use the os.add_dll_directory instead?
Why am I spotting this now? I've changed my build processes to use
a venv. I have installed tools that use an older PyQt5 and then
build the updated tools using the venv.
Barry
More information about the PyQt
mailing list