I had created with tkinter an application.
this application (python.py) contains a button, by clicking on the button it calls scripts (scripts that I have already created before) and executes them.
I was able to convert python.py to python.exe with pyinstaller (pyinstaller --onefile python.py)
after this step I put my python.exe and pycache and all the scripts (with extensions py) that I should use on my application in a single folder and open the folder in NSIS … so you can send it to another user who doesn't have python
On other pc : the application opens but as soon as I click on the button to have the execution of the scripts I have an error
python was not found; run without arguments to install from the Microsoft store, or disable this shortcut from settings > Manage App Execution Aliases.
I fix it with disable app python on manage app execution aliases. (I don’t know if it correct), but I tried to run it again and I have this error
python’ is not recognized as an internal or external command, operable program or batch file.
yet everything works fine on my pc
knowing that I work on windows
maybe i forgot a step?
Python interpreter is not installed on the target PC. Bundle your executable with all dependency libraries necessary to run your application on any windows PC. Also note that your windows version matters too.
Related
On a Windows machine, where I have no admin rights, I've created a python script which loads a module that is only available in Spyder development environment. To run it, I have to open Spyder, select the script and the working directory, before actually running the program.
I'd like to automate those steps. The ideal way would be to run the script from a console (in the correct directory), loading the python modules available in spyder.
Something like:
spyder.exe myPythonScript.py
Any idea about how to do it?
Please tell me how to package my project correctly in exe and bin.
I have tried to do it via nuitka on Linux and virtual Windows.
On Linux, I use this command:
python -m nuitka --standalone --follow-imports --output-dir=relize-linux --enable-plugin=tk-inter --enable-plugin=numpy --disable-console --product-name=aigod --linux-icon=aigod.ico --linux-onefile-icon=aigod.ico main.py
On the virtual Windows environment, I use this command:
python -m nuitka --standalone --follow-imports --output-dir=relize-windows --enable-plugin=tk-inter --enable-plugin=numpy --windows-disable-console --windows-icon-from-ico=aigod.ico --windows-product-name=aigod --lto=no main.py
Compiling and running the binary, both give me the same result (not opened), a pop-up window, supposedly a startup error.
The main file is just a GUI menu on tkinter, although this menu should have shown.
I also tried pyinstaller, but still cannot run the binary correctly.
I can't figure out why this happens.
upd-----------------------------------
I managed to compile the project using the command:
python -m nuitka --standalone --follow-imports --output-dir=relize-linux --enable-plugin=tk-inter --enable-plugin=numpy --disable-console --product-name=aigod - -linux-icon=aigod.ico --include-package-data=classify --include-package-data=data --include-package-data=models --include-package-data=segment --include-package- data=utils main.py
But the catch remains, I have additional scripts that are called via import script2 at the right time. As I understand it, their dependencies were not determined and the project did not introduce them, plus they are in the main folder along with the main script. I tried putting them in a separate folder and trying to account for them with --include-package-data=otherfiles, but that didn't work. Tell me how to take them into account too, they are important because the main script is just a menu, and the rest of the scripts do all the work. Of course, I will try to look at what it writes in the console during the next package, since in this one I indicated without a console.
I am trying to make a command-line application using Python.
I have developed the program, but I see that my program gets executed in cmd.exe, which seems to be the default for that kind of programs.
But I would like a finer GUI, like that of Windows Terminal. But the problem is that, Windows Terminal is not installed in all Windows computers as is cmd.exe.
Because of this I would like to request you that to suggest any methods to make the GUI or a method to bundle up Windows Terminal with my Python program.
So first we need to understand some terminology. You compare Windows Terminal and cmd.exe, but those are actually two entirely different types of applications. CMD is the old Windows shell. It runs inside a terminal emulator (a.k.a. terminal). There are multiple terminals that it can run under in Windows:
By default in Windows 10, it runs in the legacy Windows Console Host. This is the nearly 30 year (maybe more) old terminal for Windows.
CMD can also run inside Windows Terminal, the replacement terminal by Microsoft that is available to install in Windows 10 or Windows 11. Under Windows 11, it can become the default terminal for Windows.
When you ask Windows to run a console/terminal app, like your Python CLI app, Windows always runs it in its default terminal -- Under Windows 10, that is always the Windows Console Host. Under Windows 11, it may be either Windows Console Host or Windows Terminal, depending on the user configuration.
But there are also multiple other terminals that can run your CLI Python app in Windows:
Some of the more popular are:
ConEmu
Cmder
MobaXterm
You can find others listed in this blog post.
So it's really not that your app runs in CMD, but that your app runs in Python (the interpreter), which is running under CMD (the shell), which is running under Windows Console Host (the default terminal emulator).
Note that Python can also run under other shells (PowerShell, Linux shells under WSL, Nushell, etc.). These shells can also run in any of the terminals above. Or your Python CLI app can run as the top-level inside a terminal.
Ok, now that we've established some basics ...
But I would like a finer GUI, like that of Windows Terminal.
It's a bit unclear what you mean by that, but there may be other solutions than trying to package Windows Terminal. Both the legacy Console and Windows Terminal should have similar capabilities for your application. Windows Terminal adds things like tabs for the user, but you won't have control over that in your application. Both Console Host and WT can be configured with the same Windows fonts.
One thing you can do in Windows Terminal that you can't in Console Host is define a Profile for your application, including the themes, background image, etc. that you want it to run under. Perhaps that's what you are asking for, but you don't specify that those capabilities.
suggest any methods to make the GUI
If you are looking to create a GUI in Python, consider building it using a GUI Framework rather than as a CLI application. You can even write a terminal emulator in Python, but that would likely be a bit overkill for this.
or a method to bundle up Windows Terminal with my Python program.
That's probably not a good idea. Windows Terminal works best when it is installed as a Microsoft Store app (a.k.a. UWP, Modern, etc.). It is not possible to bundle Microsoft Store apps with another application; just like you can't install another Apple App Store app automatically from another on iOS. It's also possible to install/run Windows Terminal as a traditional .exe, but that's not the default (or supported) way.
You might consider the following:
Have your main Python app be a "launcher" that checks to see if Windows Terminal is installed, perhaps by looking for the existing of the wt.exe.
If Windows Terminal is installed:
Check for the existence of your applications JSON fragment in the appropriate directory (see link). Install it if it doesn't exist.
Launch your application by calling something like wt.exe new-tab --profile <your_app_profile> to start or open a new tab in Windows Terminal with the profile you defined in your JSON fragment.
If Windows Terminal is not installed:
Recommend that the user install it. Open the Microsoft Store link to it.
If they choose not to, your launcher should still launch the CLI portion of the app -- Windows will use the default terminal, which should be Windows Console Host.
Provide the instructions for running the CLI portion by itself (without the launcher) so that users of other terminal emulators can run it inside their preferred environment.
I'm trying to get Google Cloud SDK working on my Windows 10 desktop, but when I use the SDK shell (which, as I understand it, is just command line but with the directory changed to where Cloud SDK is installed), running 'gcloud init' returns the following:
'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
It then finishes the configuration and tells me 'Your Google Cloud SDK is configured and ready to use!' However, whenever I run any other commands, I get the same error popup again before it continues doing whatever the command does. I believe Python is installed correctly and added to Path, and when I call python from the same command line, same directory as my 'gcloud init' call, it functions as expected and opens a python console. Any ideas at what the problem might be? (or if it will even affect anything?)
Go to -> "start" and type "Manage App Execution Aliases". Go to it and turn off "Python"
I have a script (Shell, chmod-ed to 755. Python is in the script, meaning not run from an outside .py file) that is executable. It works when I run it. How can I make a .app that executes said script on runtime? I have a simple .app that has this structure: APPNAME.App>Contents>MacOS>script
This does not run. Is there any way I can piggyback a script onto another application, The Powder Toy, for example? I'm not new to OSX, I just don't have root privileges and can't install XCode.
Rembember, I can't install anything from source or use setup scripts, effectively annihilating py2app as an option.
EDIT:
This answer is courtesy of mklement0. Automator lets you choose the environment to run your script, type it in, and bundle it into a .app, removing the need for a shell script.
Run Automator and create a new Application project.
Add a Run Shell Script action.
In the Shell: list, select the interpreter of choice; /usr/bin/python in this case.
Paste the contents of your Python script into the action and save the *.app bundle.
if your using applescript, just save it as a bundle by save as, and click the drop down saying script, change that to bundle i think. after that, click on the bundle icon in apple script and drag the script to the folder you want. to run it put your run command in and drag the script that you placed in the bundle folders before in the directory slot of the run command. i can not give you anything exact due to the fact that i am not on my mac, but i am giving you the best i know.