How to run GTK3 Python3 script outside of MSYS2 in Windows - python-3.x

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.

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.

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.

Related

"Failed to execute script pyi_rth_qt4plugins" error while running exe

I have made my application using PyQt4 and it's executable using pyinstaller. The executable runs fine on my system. My system also has PyQt5 installed.
The problem is that when I try to run the same executable on the target system(client's system), it gives me an error Failed to execute script pyi_rth_qt4plugins. The client system doesn't have Python or any version of PyQt.
I wanna know why is this happening. I'm not even able to locate where is the pyi_rth_qt4plugins located in the executable. Do I need to install Python and PyQt in my client's system as well?
As per the answer from the long thread here https://github.com/pyinstaller/pyinstaller/issues/2461
In site-packages (where PyInstaller is located) edit the following file:
PyInstaller/loader/rthooks.dat
Remove this line:
'PyQt4': ['pyi_rth_qt4plugins.py'],
This error also occurs in Python3.5 if you are using 3.5 you can downgrade to 3.4 to avoid the error
check here https://github.com/pyinstaller/pyinstaller/issues/2207
or if you don't want to downgrade python you can upgrade to PyQt5

Python cross-platform portable script

I am working on a web scraper in Pycharm. The project consists of around 5 python files and 8 dependencies. I have a virtual env setup in the IDE. How do I package the files and dependencies so they can be saved on any platform and executed from the command line? I looked into Pyinstaller, but it looks like Pyinstaller only creates executables for the OS it is running on. So I would need to create 2 executables for windows and linux. And, I am not necessarily looking for an executable, just need to be able package it so anyone can download it and run it easily.

report lab libraries not working when python 3.5 script is run from OSX Automator

I have many python 3.5 scripts to handle my business affairs. All of these run perfect from IDLE and from the bash shell. When I create OSX Automator apps they all run well except the included reportlab functions do not work. I have also attempted to create the app with py2app but this fails to find the qt4 and reportlab libraries and fails. Any suggestions?

Running a standalone exe made from python 3.5 in windows xp

We created a python program with tensorflow in python 3.5. Based on our research python 3.5 and tensorflow are not supported in xp. But if we converted it to an exe file using cx_freeze, will it work?
The situation won't be any different if you use cx_freeze. There's still the same Python interpreter (just without the interactive shell), and the same libraries (packaged more conveniently), and your scripts (in the form of .pyc files, i.e. Python bytecode). The .exe file you see there just initializes the interpreter (which resides in a dll) and commands it to execute your script.

Cross-compile Python in Ubuntu to run on Windows

I need to compile a python script for a project. I am programming it in my Linux(Ubuntu) environment, and I need to have the finalized product be a .exe file to run on windows.
--It needs to be compiled so that the windows machine receiving it doesn't need to have a python environment installed on it.--
I know pyinstaller can compile scripts into executables, but it doesn't do cross-compiling.
An older version of pyinstaller does, but it only supports python2.6
The problem is, I need python 2.7 or 3.+ for my project.
Is there a program I can use to accomplish this, or maybe a workaround... something?

Resources