I'm trying to covert a python tkinder gui into an executable for my collogues with pyinstaller. The console output states that it always runs successfully however when I try to open the .exe I get an error message saying
Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access them.
I can't find anything online that has been helpful and I'm hoping someone might be able to give me a useful hint here.
My initial run is with pyinstaller my_script.py --onefile --windowed and after the spec is created I'll update the datas array to include a .json file that is needed for the script in the form of datas=[('my_json.json', '.')], (it lives in the same folder as the python script). After all this I'll rerun pyinstaller as pyinstaller my_script.spec. But still no luck.
I've notice that in other forums when people post their console output there's a line that states:
3780 INFO: Updating manifest in C:\Users\PATH_TO_THEIR_SCRIPT\dist\their_script.exe
Where as mine states:
3780 INFO: Updating manifest in C:\Users\PATH_TO_MY_SCRIPT\dist\my_script.exe.notanexecutable
Why does mine have the "notanexecutable" appended?
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 have created python desktop software. Now I want to market that as a product. But my problem is, anyone can decompile my exe file and they will get the actual code.
So is there any way to encrypt my code and convert it to exe before deployment. I have tried different ways.
But nothing is working. Is there any way to do that?.Thanks in advance
This link has most of the info you need.
But since links are discouraged here:
There is py2exe, which compiles your code into an .exe file, but afaik it's not difficult to reverse-engineer the code from the exe file.
You can of course make your code more difficult to understand. Rename your classes, functions to be non-sensical (e.g. rename print(s) to delete(s) or to a()) people will have a difficult time then.
You can also avoid all of that by using SaaS (Software as a Service), where you can host your code online on a server and get paid by people using it.
Or consider open-sourcing it :)
You can install pyinstaller per pip install pyinstaller (make sure to also add it to your environment variables) and then open shell in the folder where your file is (shift+right-click somewhere where no file is and "open PowerShell here") and the do "pyinstaller --onefile YOUR_FILE".
If there will be created a dist folder, take out the exe file and delete the build folder and the .spec I think it is.
And there you go with your standalone exe File.
I am trying to turn a .py file into .exe so that it's runnable on other computers without python. I followed this tutorial, installed pyinstaller then ran the command pyinstaller --onefile IRV.py without the -w since my program runs in the console. It successfully built the .exe file but when I run it it immediately closes even though the program itself asks for input at the beginning. It uses a bunch of .txt and .xslx files from the folder of the .py file so I dragged the .exe out of the dist folder but it still gives the same error. I managed to make a quick print screen before it closes and it gives me this error: https://imgur.com/a/w7TVjaN
The script doesn't even work if I double click the .py file. However it runs perfectly fine if I open up the .py file in an IDE like Spyder. When I run the .exe file it opens up the cmd for a few seconds with nothing written on it and then quickly writes that error I managed to screenshot and then closes. If I double click the .py though it instantly closes without the wait or the error message.
Pyinstaller didn't find the libraries or modules you imported. In the build folder that was deleted in the tutorial, there's a text document that shows warnings for libraries that aren't found by the pyinstaller. You may need to check that.
This Q&A mentioned a problem that is related to your Question: No module error when running python script from command prompt
I'm trying to run pyinstaller in python exe file in order to someone without python can use pyinstaller but no idea how to do it.
I tried import PyInstaller with other needed modules and convert this script to exe but I got error "The 'PyInstaller' distribution was not found and is required by the application". I also tried to pack PyInstaller exe file but didn't worked too. Python 3.6.5
Any ideas how to do it?
Unfortunately, what you're describing is not possible with PyInstaller. I submitted an issue on GitHub, and this is what one of the developers said:
Nope, this won't work.
PyInstaller internally uses a lot of sub-processes where it is assumed that sys.executable points to a python interpreter (e.g., here); this is not true in a frozen application, where it points to the frozen executable, which ends up in effectively endless recursion.
Even if this was not a problem, the frozen application includes only a subset of python environment, so it cannot be used to freeze an arbitrary script (not to mention the issue of 3rd party packages).
So whatever use case you have for this, it cannot be supported by PyInstaller.
check the requirements for the Pyinstaller from this link initially
https://pythonhosted.org/PyInstaller/requirements.html
Then install Pyinstaller by,
pip install pyinstaller
To create .exe file use this command for basically,
pyinstaller your_script.py
To run the created .exe
METHOD 1
Do double click the .exe file in your directory.
METHOD 2
In your cmd prompt load in to your current directory or project directory then do
: .\dist\your_script.exe
because the create .exe files are saved in dist folder inside to the project folder with the name of your script file names only.
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.