Having problem getting python script to convert to exe using pysinstaller - python

I am running pyinstaller on a python program with 4 constituent files. The main file calls the others using the subprocess call method. After the conversion is done, I click a button in the application UI and then it returns this error. Do I need to re-write the original code or is there an easier fix?
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
I expected on clicking the button that a new window would open as it was written to do.

Related

trying to run outside exe file from python freezes

I'm trying to run an executable file called CDQ.exe (which is supposed to create a text file) from within a python script. I'm using os.system(CDQ.exe) to run it. When I start the python script, the program freezes upon the os.system() call. I also don't get the text file. When I opened the task manager, I found CDQ was still running, and it kept running until I ended it.
When I try to run the CDQ.exe from the windows file browser by clicking it twice, the program appears for a couple of seconds in the task manager, then it closes, and my text file appears.
The executable file was created from c++ qt, and I'm using windows.
Does anyone know what's going on?

How to create a .bat file that starts Maya and calls a python script at startup using evalDeferred?

I'm attempting to run a python script that creates a custom menu inside Maya when a .bat file is opened to start Maya. The python script is not inside the Maya project and I wanted to add the path in the batch file. I have this in the .bat file:
start D:\TOOLS\Maya2019\bin\maya.exe -command evalDeferred(python('execfile(\"D:\CustomMenu_startup.py\")'))
Several attempts already but it's returning a syntax error.
solved by using:
start D:\TOOLS\Maya2019\bin\maya.exe -command evalDeferred(python(\"execfile('D:\\CustomMenu_startup.py')\"))
I'd suggest that, as a rule, it'd be better to push the deferred evaluation into the python itself. That way you don't have to think about it in all 3 languages (BAT, MEL, and Python).
There may also be parts of the work you can execute before the main Maya event loop kicks in, which will save some startup time -- evaldeferred is the safe choice before touching the Maya UI or the scene but you might have other jobs (like downloading files or checking the user's disk) that can be done safely while Maya itself is still loading. That's another reason to do the deferred part in Python instead of in the outermost MEL call.
If you're interested in generating launchers like this you can simply distribute a mel file instead of the BAT; MEL is executable by Maya as a file argument so your commandline gets simpler and if you have the correct file associations set up it's double-clickable.
You might also want to check out these blog posts about how to create python launchers for Maya:
https://theodox.github.io/2018/pythonception#pythonception
https://theodox.github.io/2018/keystone#keystone

Failure to run the exe file

I have written a simple software for creating passwords. But when converted to exe and run file, the terminal screen closes after about 1 second.I have also installed all the modules. The software is available at the link below.Please help me.
https://gofile.io/d/0G6N1o
The reason it is closing is because your application completed. You either need to have a dialog box which allows the user to click close, or at a minimum a sleep before you call exit(). This is the same for a .bat script in which the behavior you describe is a terminal window flickering for a second and going away.

Repeated calls to ArcMap Python Add-In with wxPython fail after one successful call

I have written a Python Add-In for ArcGIS program ArcMap that uses the wxPython package to generate a wx.Frame window with multiple controls, including an Exit button that closes the window.
The Add-in works as intended the first time I run it, and I can close the wx.Frame window using the button without any errors. However, after a variable number of times running the Add-in, I get a fatal error on running the Add-In again. (Sometimes it fails the second time I run it. Sometimes I can run it multiple times before it fails.) The error window asks to send the report to ESRI, but unfortunately, the only output that ArcMap generates in this case is a .DMP file, which I assume is simply a memory dump. I don't know how to interpret it.
The Python script that is wrapped in the Add-In works fine from the Python command line in ArcMap (with suitable modifications), but running it from a button on an ArcMap user toolbar is more convenient.
Is there any way to generate a trace of what exactly was happening when it encountered the fatal error? There is no error message sent to the Python command line window when it fails.
I was able to find an answer to this problem from a link in a posting on the ESRI GeoNet Community forum:
https://community.esri.com/thread/99532
(You need to logon to a free account on the forum to read the postings.) The original link was to a presentation by Mark Cederholm at the ESRI Developer summit 2010. The link in the forum post was obsolete, but I found another link to it:
https://www.esri.com/videos/watch?videoid=1229&isLegacy=true
that worked. The presentation shows how to build an ArcMap Extension which contains a toolbar and a button that loads when ArcMap starts. Instead of using wx.Close() or wx.Destroy to close the windows, it simply hides them using wx.Show(False). This approach allows using wxPython GUI interfaces on dialog boxes that can be opened, closed, and reopened repeatedly without crashing ArcMap.
I thought that this would be useful for other people using Python to build Add-Ins for ArcMap that make use of wxPython. Next, I will be converting another ArcMap Add-In that I currently use that was written in VB.NET in Visual Studio to Python using wxPython to build the GUI interface.

py2exe - Can no longer Copy/Paste text from other Windows app to my Python app after converting my python script to a .EXE file

I recently tried to convert one of my python scripts (used for file-systems I/O) to a executable file by using py2exe. However, after successfully generating the .exe file from my python script, I am no longer able to copy and paste any text(or anything for that matter) from other windows apps to my python app console (when I run the script/app from the .exe file). When right click the mouse now, the access window does not pop up any longer. Does anyone know how I can get around this issue?
Thanks,
A.L.
Right-clicking a console window is a "special feature" of the command line interpreter of Windows Vista and above. It doesn't work on any other command-line tool, so it doesn't longer works for your converted script. You can still access it using the windows menu (small icon in the title bar or Alt+Space).
You could try to get the right-click feature back by messing around with Windows API calls - but the more convenient possibility would be to enable pasting using Ctrl+V and forget about the window menu. A good candidate is PyReadline - install the package and run this at the beginning of your script:
import readline
readline.parse_and_bind("control-v: paste")

Categories

Resources