0
votes

How can I make my GTK3+ Python script work outside of Msys2's own Python interpreter, into my own venv (virtual environment) Python3 interpreter? I want to prepare my Python 3 script for distribution to other computers, but without Msys2.

I'm using Windows 10.

I've successfully followed the instructions on GTK's website, to download GTK3+ and the Python bindings, in Windows.

I've installed GTK3+ and the Python bindings using MSYS2. My script runs successfully within MSYS2's Python3 interpreter in C:\msys64\mingw64\bin. However, I want to run my Python script outside of MSYS2, with a separate Python 3 interpreter (venv) - not the one in MSYS2.

From my research, it seems that I need to copy the GTK3 .dll files and icons from C:\msys64\mingw64\bin and C:\msys64\mingw64\share

to the Python3 interpreter path that I want, with my script files in there too.

But when I attempt to run my script in the virtual environment, I get:

builtins.ImportError: cannot import name '_gi' from 'gi'

Any ideas? Thanks.

2

2 Answers

1
votes

I don't know if that is possible.

But if the final intent is to distribute your app, then you should install PyInstaller inside MSYS2 and generate an executable there. Then you'll be able to distribute and execute your app on any Windows machine.

0
votes

It will only be possible to run your program using the MSYS2 Python interpreter and with all of the required libraries. You can't just copy files and then run them with the Windows Python interpreter that was built using MSVC.

PyInstaller is a good solution to package an app with the interpreter and all of the libraries. The issue you mentioned about getting errors about no module named '_struct' has been fixed.