I have a python script that uses the face_recognition library(as well as other libraries), and want to make an .exe file out of it. I use pyinstaller, but I get the following error when trying to run the .exe file:
I guess it needs a hook or something, but I am not really familiar with how to write one or what the contents of it should be. I had a similar problem in the past with another python script I was trying to make into an .exe file, and luckily someone knew how to help me out. It would be great if someone could guide me through this.
Since the exe is complaining about a missing module "pkg_resources.py2_warn2 add --hidden-import=pkg_resources.py2_warn to your build command
To complete the job you should read https://github.com/ageitgey/face_recognition/issues/357
If you're trying to make an .exe file with libarys, I would recommend using https://pypi.org/project/auto-py-to-exe/ auto-py-to-exe, i've used it many times and it works great.
I had the same error.
I fixed this by adding the required libraries to the python environment that auto-py-to-exe or pyinstaller uses
Related
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 have used several tools (pyinstaller, cx_Freeze, py2exe) to convert my .py file to .exe file. But with each one of these, the resultant .exe file closes as soon as it runs. Here is a screenshot of the exe file created form pyinstaller.
I have looked at several answers on SO and other platforms but haven't been able to find a solution. Any help would be greatly appreciated.
My apologies for not being able to type these traccebacks out here as I had to take a quick screenshot as the window closed in a second.
The .py file runs fine on its own; there's no issue with the code.
I had this problem about a year ago with pyinstaller and this 2 methods helped me:
Adding import pkg_resources.py2_warn to my script
Using --onedir instead of --onefile
You can also do it using cmd:
pip install pyinstaller
cd followed by the location where your Python script is stored
so an example is:
cd C:\Users\Ron\Desktop\MyPython
then:
pyinstaller --onefile pythonScriptName.py
instead of pythonscriptname.py, put in your python file name.
When you do this there should be a new file called dist in your directory. Wait for a few mins and there should be an .exe file in there.
Here's a temporay solution: I removed all imports related to the googleapiclient for google docs. The .py file gets compiled properly after that.
More Context: There seems to be some issue in this particular library library that causes issues. I have tested the given solutions, they don't seem to work for me. I'll update this answer if I find a "permanent" solution.
I’ve recently tried making an .exe from my .py file.
(This is my first time making a .exe)
It’s a long script and includes this cool function.
If I compile this to a .exe
It works just fine on the PC I code on, but not on another PC. Which makes me believe there is something missing during the pip installer ?
To compile this script I need to have ctypes Installed,
and in the cmd say: pyinstaller filename.py
Am I missing something ?
I don't have any error to show unfortunately, it just stays blank after it tries to run wait_until_idle.
The most trusted/automated way that I found to make an exe out of python code is this package:
https://pypi.org/project/auto-py-to-exe/
I tested it myself on multiple situations with whole projects not just single/small scripts.
The main disadvantage of this is the size of the exe file, it's really big and specially if you are using external libraries like pandas, numpy could easily make your exe pass 100 Mega bytes.
It's a simple graphical UI that you could use to generate exe, There is no external dependencies you need to install separately.
I am trying to create an .exe file such that when run on any windows 10 pc will run without requiring any installations. What I tried using was:
pyinstaller --onefile main.py
I ran the exe file on a friend's computer and it turns out that it required first python2.7 to be installed, then it said that modules weren't installed i.e; no module named datetime found. The executable finally ran after I installed all dependencies on my friend's computer but the whole point of creating .exe file was useless, I might as well have just typed python main.py after doing so much. Is there an appropriate way I could get an .exe file from .py which wont require anything to be installed? Like an actual standalone app. Thank you!
Actually this should work. I never had problems with pyinstaller, yet. Maybe reinstall pyinstaller or make sure to use the newest version. Also try first of all an easy "helloWorld"
input("hello from Console.\nPress Enter to close it :)")
Just tried this one on a colleague's machine that has no python installed. And it worked well.
I've had good results using the pyinstaller module to one file even when running code with multiple dependencies on machines without python installed. Reading the documentation helped There is a comprehensive list of python to exe compilers in another stackoverflow question: a good python to exe compiler?
NOTE: Before marking this as duplicate please read the whole post first
I'm trying for hours to convert my python 3.6 code to exe, I've searched everywhere and tried everything, the most helpful place was there:
Best method of converting .py to .exe for Python 3.6?
So apparently there are only 3 ways of converting py to exe:
PyInstaller
Py2exe
Cxfreeze
Pyinstaller doesn't support Python 3.6, and py2exe is very outdated.
As for cxfreeze, it sounds like it supports Python 3.6, so that's the route that I've taken.
I've searched everywhere on how to use cxfreeze, unfortunately, all guides that I have found seem to be outdated:
http://cx-freeze.readthedocs.io/en/latest/overview.html this guide for example has three routes, two of which doesn't work (The first gives me a .spec file that i dont know what to do with it and the second gives me an error because i dont have the cxfreeze.util module) and the 3rd is too complicated for my tastes
How do I use cx_freeze? this uses the second route, still it doesn't work
I'm not allowed to comment for some reason, so this isn't really an answer, but for my part I installed cx_Freeze from https://pypi.python.org/pypi/cx_Freeze
When you install it, there's an extra step that's not documented. Using the Windows CMD shell, go to your python installation directory, into the Scripts sub-directory and you will find a few files called cxfreeze...
You need to create the batch file by typing python cxfreeze-postinstall
A file called cxfreeze.bat will be created which you can move into your main python folder or wherever your python program is located.
Then type cxfreeze mypythonprogram.py --target-dir dist
This should create a working exe in the dist directory. However, it doesn't work for me as I get an error in the finder.py file which is part of the cxfreeze installation so I don't know if I've done something wrong or this version is completely buggy.
edit: by commenting out line 561 in the finder.py file (C:\Python\Python36-32\Lib\site-packages\cx_Freeze\finder.py on my system) I was able to run it and Generate the EXE which appears to run OK.