I know that the title may not be very clear so here's my problem below:
I've made a mini application in python for contact management (it's a simple program.py + a notepad where the information are stocked+some photos). I've made an executable (.exe) to share it.
I've made it with pyinstaller. The .exe works pretty well on my laptop but don't work elsewhere. The error messages are the following:
No error messages generated.FormatMessageW;Parametre incorrect.
Then when I click Ok there is a second one:
Error loading Python DLL 'c\users....\_MEI50282\python37.dll
Related
I have one Py file that collects Outlook email details for analysis. I was able to get the code completed with some help referenced in this stackoverflow post. Now i'm tasked with sharing the code with other users who might not have python installed but would simply like to use it as an EXE file to get the data and do some basic analysis. I've tried various options including the following, however they all have the same error.
I've also tried this on a machine with Administrator rights.
Pyinstaller
Auto Py to Exe
Can any one provide some guidance on what might be going wrong.
The error message reads "Failed to execute script filename"
#EDIT based on 09/08/2020
While the exe file generated did not work, the pyc file that was generated worked to provide the output. However this is not transferable to another machine to work as an EXE.
I wrote a script with a bunch of modules to convert txt files to pdfs. There's a watchdog module which checks a certain folder for newly created txts, python siphons the data into a latex template which is being compiled into a pdf.
I created my abomination in PyCharm and if I start the script within PyCharm, it works flawlessly. I compiled it as exe via 'pyinstaller --onefile' and it works flawlessly.
However, I need to run it as a windows service or at least without the window existing in the task bar because... reasons. I tried:
installing it as service via non-sucking service manager
starting it as hidden programme via a vbs script, powershell script and nircmd
and nothing helped. I'm at a loss here, there's no interaction whatsoever with the programme so it should work, also scripts are enabled on the machine and the process is visible in the task manager. I somehow suspect that it has problems calling other python scripts while it's a service or hidden programme but it doesn't seem to be logical and I have no means to verify anything whatsoever that I'm aware of.
My last idea is to somehow let it exist as a task bar tray thingy but that would be more than a shabby solution for this whole ordeal. Could anyone help me out here? Thanks
I wrote a program with Qt and I embedded a .py file in it to do some work.
On my computer which has the Python interpreter installed, the program can run correctly, but when I run it on my roommate's PC, which has NO Python interpreter installed, the program crashed.
The part which is written with Qt runs well but when I push a button to call .py to do some work, the program crashes.
I think the problem is that I haven't put the std library and some other key files of Python into the folder of my program, but I have no idea what files should I pack into it.
So if the problem is really what I thought, what should I do to solve it?
Namely, which files of Python should be packaged into a program to run on the PC with no Python interpreter ?
Thanks in advance.
------------update------------------
As for the code of Python, it's just a hello-world for test and learning. I copy the whole Python34 folder into the program and the question has been solved:). Though it may not be a right way, it works.
Python's documentation has a reference manual for the C/C++ API.
The file I believe you're referring to is Python.h, though I'm no expert on this. It's considerably easier to embed C than C++, and this gives some of the more simple examples. As far as I know, you shouldn't need to worry about the interpreter for compiling to an executable.
I have written a python script with a Tkinter GUI. I would like to create a desktop icon that will execute this script so that the end-user (not myself) will be able to double-click the icon and have the GUI load, rather than 'run' the script from the terminal or python shell and then have to F5 from there.
Is there a way to do this? I have googled many arrangements of my question but most answers seem to be normal python scripts, not ones which are Tkinter based.
I am using a Raspberry Pi with Wheezy and Python 2.7
Thanks in advance.
I create executables(icons that I click to start the programs I write) using 'py2exe'. I use windows 7 and I am not sure if it would work for you with Raspberry Pi, but a google search may clear that up for you. I will provide the link below. Basically you end up with a folder with the executable(icon) and also some files, without which the executable won't work. It's unfortunate that you get this extra 'baggage', but it's still handy and the best solution I have come across. I don't think there is a much better way, but I am not 100% on that. Interestingly, I found that you could delete most of these baggage files and the executable would still work, it was trial and error, but it didn't take long. If I want to send the folder to someone, I zip it first.
py2exe is here
If you need a 64 bit binary you can get it here, along with, actually, pretty much every other version. get py2exe here also
Besides creating executable file other option is create simple .bat file:
Open notepad
Enter "C:\ProgramData\Anaconda3\python.exe" "C:\Users\Your ID\script.py"
First part is path to python.exe, second to your python script
save file as .bat file, ex. "open_program.bat"
Now simply double click on saved .bat file icon should open your script.
I like using cx-freeze to convert python scripts to exe.
There is very easy to follow documentation to do this. In short, you create a setup.py script that specifies what libraries and packages you want to include or exclude in your application.
You can then run the build in the console and it will create a build folder, in which will be an Application File. You can create a Desktop short cut using send to and selecting desktop.
Documentation link
You can save the script as a .pyw file so the user can click on the file and the GUi would open
I have an EXE that I built that I am trying to have installed in the Program Files (x86) folder on Win7 machines. There is really interesting behavior going on. The program has a gui-we used wx-Python and XRC to handle the interface. we include an XRC folder in the distribution. The program uses getcwd() to locate itself and find the xrc folder. However, and this is really interesting-it all works fine when I place the program in Program Files. When I place the program in the Program Files x86 folder I get a message that indicates to me that it can't find the xrc folder.
Let me be clear this application runs fine on an XP machine in Program Files and on a Vista Machine as well as a Win7 machine in Program Files
Now what else is interesting is if I double click the exe in the Program Files (x86) folder it runs fine but when I try to run it off of the short cut added to the start/program menus it does not run correctly. That is where I get the error message that suggests the program is not finding the xrc folder. I also moved the program to a folder on the desktop, and at the root and in every other location it starts and runs fine. Thus I am confident that my code to point to the xrc folder is fine.
So back to the question. When programs are running from the x86 folder is something happening that causes the path references to get screwy? More importantly is it fixable?
One final note- To be as certain as possible that the problem relates to the path to the xrc folder I deleted the xrc folder from two instances of the application and I get the same error message that I received when the program was installed in the x86 folder.
Just for clarification the only time the program will not run is when I use the shortcut on the start menu and the exe and all of the parts are saved in the Program Files (x86) folder
Plasticsabers answerreally helped me understand the problem and I was able to fix it. This is not a Vista verus XP issue it is a 32 bit OS versus 64 bit issue.
I need to run on 64 bit XP and 32 bit Win7.
According to this note, the Program Files (x86) folder is specifically intended for 32-bit program files, as opposed to the Program Files folder, which is intended for 64-bit programs.
But in order for a 32-bit program to pretend that it's on a 32-bit machine, the name of the working directory has to be returned as 'Program Files,' because that's what it would be on a 32-bit machine. This is what you're seeing when you ask Windows for the working directory with getcwd(). Since your program is trying to use that directory name in a path, and that's not actually the path to the file on the real, 64-bit machine, it breaks.
Looking at the WOW64 docs, I suspect the reason it only breaks when launched from the start menu is, that's an instance of a 64-bit process creating a 32-bit process, which causes the system to change the ProgramFiles environment variable. In the case where you double-click to launch it, it's a 32-bit process from the beginning.
It seems you're not the only one to encounter this; this Windows API seems designed specifically to work around the problem you're describing. If nothing else it suggests the behavior you're seeing is by design.
But this is academic. To insulate yourself from this sort of thing, I would get the absolute path to your exe, using something like os.path.realpath(__file__), and go from there.