Here's my situation. I used py2exe to generated some python codes to exe in Windows, everything works fine except for the file operations. The exe file cannot create open, read or close files while the python scripts works fine.
It is a simple pyqt program that only includes some dialogs, string operations, and saving the results into a file.
Anyone has any clue about it? My python version is 3.4 and OS is Win7
Related
I have a Python application built under PyInstaller on a MAC. I do not want to have a terminal window when it is running so I specified the --noconsole option. Apparently, under MACos, this option still provides a console (terminal) window if you use the EXE file. If you use the MAC application package to start, then you do not have the console/terminal window.
The problem is that the program reads a data file at initialization. When I run the EXE, that data file is in the same directory as the EXE and it loads fine. But when it runs as an app, it reads from the default working directory and I have no idea where that is. So it can't find the data file required. And reading further it seems from MAC OS to OS the working directory location might change. I moved the data file where the EXE is in the MAC application, but when Python reads that is not the directory it is reading from.
So how can I place the required data file somewhere the Python application (not running the EXE directly) will find it.
Under Windows, the data file is just in the same directory where the EXE is running and there is no console window. There is no concept of the MAC application type. But if I don't want to have the Terminal window, I need to resolve where to place a data file so that will be found.
I suggest digesting some of these basic Apple macOS developer documents. All your answers will come through understanding these.
Bundles
Codesigning
Information Property List
Entitlements
Embedding Non-standard Code Structures
I would like to create an executable file from my python project that consists of one python file that uses gecodriver.exe, I have tried using pyinstaller for this matter, however the program closes as soon as it opens, basically it doesn't work. I suspect that the .exe file that is created by pyinstaller does not include or cannot see geckodriver. Any sugestions how to make it work will be helpful.
I Created a Program That Has 2 .py files.
I Want To Make The Program a .exe file, I do it using cx_Freeze.
My Problem Is That I Convert The main.py To .exe but The Second Python File Is Still a .py File.
I Don't Want It Be a .py Because If It Is The User Can See The Code.
If I Also Convert The Second Python File The Program Doesn't Work Because I import The Python File In The Main File.
Any Suggestions?
(I Don't Want To Copy The Second Python File To The Main Python File)
You are chasing the wrong rabbit here. The various tools that generate executable files from Python code are not compilers. They are just tools that embed a Python interpretor with py (or pyc) files to allow users to use the program without a prior Python installation.
Said differently you should not use them to hide your code (except from people not knowing a lot of Python): a pyc does not contain text code but according to the answers to Is it possible to decompile a compiled .pyc file into a .py file? , tools exists that convert back a pyc file into a py file (of course except the comments).
IMHO, you should better google for python obfuscate to find tools dedicated to obfuscation, what neither cx-freeze nor pyinstaller are.
BTW while there are appropriate use cases for obfuscation you should be aware that a determinate attacker can always circumvent it. The reason why the real protection for intellectual property is law and not technics...
I'm not sure how two or more .py files can be converted to .exe.
But in python the easiest way to convert to .exe is a module named pyinstaller .
You can install it using command pip install pyinstaller can get it . After just go to the directory where your project files are and open command prompt in that directory and execute pyinstaller file_name
I wrote a program in Python that includes external files, including images and a GUI .ui file.
I want to convert the Python script to a single executable (.exe) file using PyInstaller. When I try to open the .exe file, the program does not open.
You will need more information on why the application is closing immediately in order to solve your problem. To view the error messages associated with running your executable, run the .exe file from the command prompt: /path/to/app/dist/MyApp.exe. This will allow you to observe any errors that may exist after the app was bundled. If the program fails during an import statement, you may need to add a package to the hiddenimports list in the .spec file. Check the PyInstaller documentation for instructions on modifying the .spec file.
I have made a python file and converted it to executable file with pyinstaller in Ubuntu, now I want to run the same executable file in windows, how would I do that?
Oups... Programs exists in different formats, normally text (.py for Python), byte code (.pyc) for Python and native executable formats. Text is normally portable across any architecture except for possible charset conversions. Byte code is normally portable, I am sure for Java, less for Python because I have never used it. But native executable formats (true executable in Linux or .exe files on Windows) are dedicated to one single architecture.
So a program generated by pyinstaller on Ubuntu can only be used on a Linux system with same system libraries as yours (read Ubuntu same version, even if it should also run on some other Linux flavours), but definitely not on Windows.
You have to install pyinstaller on windows, and run pyinstaller on windows (From the OS that you want to build your exe file)