Application is not working under raw system - python

I've an python GUI application, I use pyQt4.
I build binary with bbfreeze (before I was using py2exe but it didn't work with email module well).
On system where I build this app, everything works properly, but when I install it on raw windows (without all those vc_redist and set of python libraries) binary does not work.
Where should I start to find a solution, since I have no messages/exceptions/crashes, it simply ends immediately after i run it from command line.
I predict that if I'd install some of tools from "build system" I would run it.
Is this the only way?
I mean, if I would find the missing lib (if it's a lib problem), would adding this library to bbfreeze script would solve this problem?
cheers
P.

Get Dependency Walker, and run depends.exe on your executable. It will examine the full tree of DLL dependencies, and mark with a red error the ones that are missing.
It will likely be a MSCVRTxx.dll.

Related

How do I install Gimp-Python on windows?

I try to write a simple plugin with gimpfu in python and I tried following those instructions.
1.2. Installation
Gimp-python consists of a Python module written in C and some native python support modules. You can build pygimp with the commands:
./configure
make
make install
This will build and install gimpmodule and its supporting modules, and install the sample plugins in gimp's plugin directory.
Where do I have to execute those commands?
I tried adding my script to the plugins folder but it seems like there is no python module called gimpfu. I believe I have to enable or install it in some way, but I can't find a solutio to do it.
EDIT: It seems like gimpfu is availible in the gimpfy-console insode gimp. It just doesn't seem to be availible for my plugin scripts.
No need to install anything. In the Windows versions Python support is built-in, and the gimpfu import is available when your code is executed by Gimp.
If you don't see the plugin in the menu it is likely a syntax error that doesn't let it run its registration code. See here for some debugging techniques.
However, since you mention PyCharm, you may have another Python interpreter installed and this makes things complicated because there can be conflicts depending on order of installation (and remember, Gimp uses Python 2.7)
Now it all depends if you are really doing a plugin (called from the Gimp menu) or a batch (where Gimp is called from a shell script), which is somewhat different. If you are writing a batch, see this answer for an example.
you don't need to install anything, on windows gimp comes with a python interpreter along with the libraries inside of it.
if you want to run your script from inside GIMP then you should check this answer and you should add the path to gimp to your system PATH environment variable (which is C:\Program Files\GIMP 2\bin on my system) , and instead of calling gimp-console.exe you should replace that with whatever gimp-console is currently available in that folder, the one on my system is gimp-console-2.10.exe.

any known way to create a device-to-device portable self-contained python runtime?

I want to distribute a python program on, say, Windows and/or Mac, but I don't want to give the user the headache of ensuring there is an appropriate python runtime installed on their machine. And i don't want to interfere with their machine's configuration by, let's say, requesting root privileges and installing a system-wide python runtime on their system that suits my program specifically because it's too invasive and might cause compatibility collisions with other installed versions of the runtime.
I would much rather have a self-contained executable that could be, for example, stored on a USB flash-drive, inserted into the system, and then maybe with a stepping-stone binary executable that just invokes the device-portable runtime on a python script that I provide, I could then run the program as if it were a self-contained binary executable (with only standard-library dependencies).
A link to this binary executable could be published into main-menu program lists, docks, or desktops. And it could be invoked by shell scripts or other executed-by-proxy mechanisms. Such a no-install/self-contained python program could potentially be a first-class user-invokable application. This is what I want to achieve.
I googled around for projects that provided a device-portable/mobile python installation and so far I've only found portablepython.com. Unfortunately it says the project is discontinued and no download link for the project is provided. it listed some similar projects but they all seemed defunkt or with a very different focus.
Does anyone know of an active project that is or includes such an independent/portable/mobile/no-install distribution for python?
or is there some way i could configure python's build system to build a noinstall-friendly product?
any ideas welcome. thanks for your input!
After more searching I found that Python.org publishes its own standalone-python distribution called the embeddable zip file.
This is exactly what I was searching for. It's a basic python standalone runtime that requires relatively few megabytes of storage.
I started with this embeddable distro and then cajoled a standalone copy of pip to work with it. Problem solved.
Improving upon #oreus2020's answer, you can download the embeddable zip file from here. Then, unzip the compressed file to a folder of your choice. Go to the root of your install and find python._pth file and open it in a text editor. Remove the "#" before import site(This file is the one which manages the environment of the portable install. If you want anything to be recognized by the portable python interpreter, just throw the path in here and that's it!). If you want pip, go to this page and save it in the root of your portable install and run it using the portable python interpreter like ./python get-pip.py from a commandline opened at the root of your install. Pip installed! To use the pip, do ./python -m pip <commands> from the commandline opened at the root of your install and then open the python._pth file and insert the following below the "." ./Lib/site-packages ./Scripts. Voila, you got yourself a python portable install!
My python._pth file looks like:
python39.zip
.
# Uncomment to run site.main() automatically
./Repo
./Repo/Code
./Repo/Code/cogs
./Lib/site-packages
./Scripts
import site
If you are still wondering, here is the link to the one I made for myself.
P.S. Pardon my bad English

How to package a Python 3 console application as a windows binary?

I am doing this practice project to implement a LISP interpreter in Python, using help from here. I wanted to create an exe file for the project, executing which would start a REPL.
I tried using py2exe and pyInstaller but an error is thrown when I execute the output binary, saying that this script cannot run.
Where did I go wrong with my approach and what alternative ways can I use?
Thank you.
It is hard to know for sure but have you checked that all of the required dependencies for your project are either in the same folder as the created executable or (at least) in your path?
The other alternative that I am aware of (and use) is cx_Freeze. This particular exe builder has cross platform support.
cx_Freeze will attempt to automatically find all dependent python modules and include them in the final build. I imagine that the other two options work in the same manner. Packages that cannot be automatically located and binary dependencies (eg dlls, sos) must be explicitly specified in the build configuration scripts.
One method I have for debugging for missing dependencies is to manually copy the suspected missing dependency into the same folder as the .exe to see if it fixes the issue. If it does then I will specify it in the build configuration script.
See https://cx-freeze.readthedocs.io/en/latest/distutils.html for cx_Freeze documentation, in particular section titled build_exe.
Here is a good example of a non-trival setup.py for cx_Freeze: http://www.pythonexample.com/code/cx_freeze-setup/

How to convert a Python PyQt based program to a portable package in Linux?

I've managed to make a single working executable file (for Windows) from a PyQt based Python app using PyInstaller, but is it also possible for Linux?
On linux machine (LUbuntu), when I run the .py script, I've got errors about missing PyQt bindings and I can't even download them by apt-get because of inability to connect the servers. It would be much more convenient to somehow pack the missing libraries to my program's files in order to make it more portable, but how can I do it?
If you package your application in the Linux distribution's package format, it can contain dependency information. That is the canonical solution to this problem.
Otherwise you'd have to include all nested dependencies to make sure that it'll work.

Cx_freeze --- Do all users need python?

I just created an exe with cx_Freeze and proudly handed it over to a co-worker.....and it promptly crashed ("The application was unable to start correctly") I was curious to know if he must have python already installed and ready to go when he runs my exe or if it is something else that I should be worried about. (If that is the case, I will do some more research)
I am using Python 2.7 64 bit, Wxpython, and Cx_Freeze 4.2.7
UPDATE:
So I have found that a download of Python 2.7 DOES indeed fix the problem--but this is not what I really want. I have heard that with the correct options selected in the setup.py script that I can truly create a stand alone--Does ANYONE know about how I could do this? Filesize is no object.
The purpose of cx_Freeze is so that the user doesn't need Python installed. But sometimes there might be some DLL dependencies that aren't sorted out automatically by cx_Freeze. For one example, see my recent question and answer for "ImportError: DLL load failed when importing win32clipboard in application frozen with cx_Freeze".
But if you're getting the message "The application was unable to start correctly", then that sounds as though the problem is some implicit-linking DLL dependency. Try using Dependency Walker to track down which DLL is missing. Let us know your results.
No, he doesn't need to have Python installed - cx_Freeze should copy a Python DLL into the build folder. Make sure that all the files in the build folder are still with the EXE when you run it.
However, it might be necessary for him to install the Microsoft 'Visual C++ redistributable' that Python requires. I don't think cx_Freeze can automatically include that, for legal reasons (but I am not a lawyer, and I'm happy to be proved wrong). The details are in the documentation:
http://cx_freeze.readthedocs.org/en/latest/overview.html#microsoft-visual-c-2008-redistributable-package
Or there may be some other problem with the bundling for your application. I don't know what would cause that error message.

Categories

Resources