I am trying to create a very simple desktop application with one python module in pynsist. Pynsist appears to be functioning correctly, and the application installs correctly. When I try to launch the application from the start menu, it appears to open briefly, but does not execute the script. To test if it was something wrong with my code, or config file, I created a very dumbed down version and am having the same issue. My config file is as follows:
[Application]
name=Please work
version=1.0
entry_point=Test:main
publisher:Company ABC
[Python]
version=3.6.4
bitness=32
[Include]
packages=Test
tkinter
_tkinter
My module "Test.py" is saved in the same folder as the config file and is as follows:
from tkinter import messagebox
def main():
messagebox.showinfo("New Box","Why don't I work?")
main()
This seems like it should be an easy fix, but am I missing something? In going through the message boards, some people appeared to have issues with tkinter; however, I was not getting any errors when pynsist created the application (as other people were getting)
Help is greatly appreciated.
EDIT: upon further investigation, it appears that tkinter though included in the application is not accessible to the installed python version that pynsist includes.
Related
I am currently working on a gui with the custom tkinter lib.
I created the .exe file by adding the CustomTkinter with auto-py-to-exe
Then I use the InstallForge software because I want to share my file.
After that I got my setup file, it works on my computer but not on my friends one.
Do you guys now why ?
I try to use other software like Inno Setup compiler but the problem is still the same, the application cant be launched.
I run is as admin : result : the application cant be launched.
Here is the files that I add in the software Install Forge
Thank you.
I have created a python script that I am attempting to turn into an application on mac so that I do not have to alway open the terminal. I am using Tkinter to create a window that the script runs on.
I run pyinstaller --onefile -w -i "Icon Name" "myapp.py" and I get the Dist folder with both a unix script and a macOS application. Running the Unix Script works perfectly fine, however when I try and run the app it will breifly blink in the taskbar and then dissapear without doing anything. running open myapp in the terminal opens it fine, its just when I double click on it.
I have tried looking it up and PyInstaller App not opening on Mac leads me to this github thread https://github.com/pyinstaller/pyinstaller/issues/3753. I tried following along however when I get to the hook-_tkinter.py file mine is only 30 lines of code and looks like this:
import sys
from PyInstaller import compat
from PyInstaller.utils.hooks import logger
from PyInstaller.utils.hooks.tcl_tk import collect_tcl_tk_files
def hook(hook_api):
# Use a hook-function to get the module's attr:`__file__` easily.
"""
Freeze all external Tcl/Tk data files if this is a supported platform *or* log a non-fatal error otherwise.
"""
if compat.is_win or compat.is_darwin or compat.is_unix:
# collect_tcl_tk_files() returns a Tree, so we need to store it into `hook_api.datas` in order to prevent
# `building.imphook.format_binaries_and_datas` from crashing with "too many values to unpack".
hook_api.add_datas(collect_tcl_tk_files(hook_api.__file__))
else:
logger.error("... skipping Tcl/Tk handling on unsupported platform %s",
It does not have the specific lines that the thread is showing I need to edit. I should also note that I found the file in /opt/homebrew/lib/python3.10/site-packages/PyInstaller/hooks/hook-_tkinter.py instead of where the thread is pointing to. I cannot find this file there.
I also read somewhere (I forget where exactly) that I need TCL and tkinter installed which I thought I did already cause it comes with python. trying to find somewhere to download tcl brought me to activetcl but I am unsure how to install that on my computer so I am not sure if that is the solution or not because I cannot get it working.
Sorry for the long question but would anyone be able to assist me in getting this working?
I was trying to convert my python script test.py to a mac app.
I followed this tutorial.
Content of test.py
print("Hello world!")
Then I created setup.py with the following content and saved in to the same folder as test.py:
from setuptools import setup
APP = ['test.py']
OPTIONS = {'argv_emulation': True}
setup(app=APP, options={'py2app':OPTIONS},setup_requires=['py2app'])
Then I navigated my terminal to the folder where test.py and setup.py are stored.
Then I installed py2app with the following command(I am using Pycharm):
pip3 install py2app
Then I entered the following terminal command:
python setup.py py2app
py2app performed multiple operations and responded with
Done!
I navigated back to the directory where test.py and setup.py are stored.
As expected, I found new directories: build and dist.
I opened the dist directory and found a file test.app there.
I double clicked test.app, an icon popped in the dock, bounced for few times, and disappeared.
*I did this with the simplest python script possible in order to figure out what the problem is. I tried to create and app from a more complex script before, in that case after double clicking the {}.app file a window poped app saying
{file name} encountered and error
and let me choose to either terminate the app directly or see the console.
Please what am I doing wrong / is there a straightforward way to turn a py script into a mac app?
Many thanks
After further googling I came across this post that discusses this problem. No that it would solve my problem, but maybe it will be helpful to somebody else.
You did nothing wrong. As there is only a print in test.py, it's normal the app starts and disappears immediately.
You can put in test.py
import tkinter as tk
tk.Frame(tk.Tk()).mainloop()
build app and start it.
Im developing an installer for a GNU/Linux distribution in Python using Eclipse+PyDev. For some tasks on it there is needed that the program runs with root priviledges, but I run Eclipse as a common user.
I had searched a lot of stuff on the Internet about how to run an app as root without having to run Eclipse with priviledges, but no a single clue of how to accomplish this in a "nice way". So I tried with the "gksu2" python module, with has the gksu2.sudo() functions in the same way as gksu in bash.
I created a new module, imported gksu2 and executed the main.py module of the app, but I got a "ImportError: No module named ui.regular_ui.wizard". It runs ok without gksu2 in eclipse, but it doesn't if I use it. I thought it was an environment variables problem, but the sys.path is ok.
The same error happens if I run the app from a terminal, outside of Eclipse. What do you think?
It seems like your PYTHONPATH is different outside/inside Eclipse. Try just removing the Python interpreter and adding it again to gather new paths -- if that's not enough, do: import sys;print('\n'.join(sorted(sys.path))) outside/inside Eclipse to know what's different and fix your paths inside Eclipse.
I made a a simple GUI program in python with tkinter and attempted to convert it to an .exe using py2exe. However, I've run into a problem. When I try to run the exe it flashes an error very quickly then disapears. So the best I could do was take a screan shot of the error.
How do I go about fixing this?
Edit
Velociraptors, this is my setup file. It's about as basic as it can be. How would I go about integrating init.tcl into the code?
from distutils.core import setup
import py2exe
setup(console=[r'C:\Python26\Random Password Generator.py'])
Does your setup.py script include init.tcl in the data_files option? The py2exe list of options says that's how you should include images and other required data files.
Edit:
Your setup script specifies that your program should be converted to a console exe. If you want a GUI program (which you do, since you're using Tkinter), you need to use the windows option:
setup(windows=[r'C:\Python26\Random Password Generator.py'])
Py2exe should correctly include Tkinter's dependencies. If not, you can manually include init.tcl:
setup(data_files=['C:\Python26\tcl\tcl8.5\init.tcl'],
windows=[r'C:\Python26\Random Password Generator.py'])
Ensure that tcl is installed in C:\Users\splotchy\lib\tcl8.5 or C:\Users\lib\tcl8.5.
If you want to see the error messages for longer, run your program from a command prompt.
I found a bug on the virutalenv site which suggested the following https://github.com/pypa/virtualenv/issues/93
for windows in your directory "C:\Environments\VirtualEnv\Scripts\activate.bat" just add which are set to the right path to TCL and TK for your python version
set "TCL_LIBRARY=C:\Python27\tcl\tcl8.5"
set "TK_LIBRARY=C:\Python27\tcl\tk8.5"
restart your cmd or shell
I believe that the TCL location have changed from there default ones.