I am attempting to create a exe file for an application that uses three .py files with functions and some libraries (pandas, tkinter, win32com...).
I want to create this for some people of my company. I'm using Anaconda as environment and tried auto-py-to-exe and cx_freeze to exe compilation. Some of the issues that I'm having are this:
I always need to disable windows defender or create an exeption to
the folder to run the final exe file
When I share it with my collegues in a Sharepoint folder it doesn't
work for them, it looks like some of the libraries are using paths
with my local folder.
The final folder with the exe file is very heavy (around 200MB)
including a lot of libraries that i don't need, some of the numpy
related libraries are the heaviest.
I will appreciate any help with this, I've work hard to develop the application but I can't share it to others and that is the objetive.
Thanks!
I've created an executable file using cx_freeze that contains a simple Python script. The .exe file works on my PC (I have Python installed) but is it possible to send it to a colleague, for example, that doesn't have Python on their machine and will it work? The goal is to package useful Python programs and make them available for others to use even if they don't have Python.
I've played around with it a little bit and it doesn't seem to work on non-Python enabled machines. I've sent just the .exe file (didn't work), just the 'build' folder (in a zip file-didn't work) and I've even zipped the whole folder that contains the .py files and the build folder-that also didn't work. However, I thought this was the point of creating the .exe file? Any guidance would be appreciated.
Thanks
So I've made a project which takes a photo of your face or you can use any image and let it be fed into a neural network trained to classify celebrities. With that, you can figure out what celeb you look like.
Here is the Video and GitHub link.
I wanted to convert it to exe so that it's easier for people to download and use it but so far I've tried cx_freeze, pyinstaller and none of them work. I can't use py2exe because I'm on python 3.5.
I was able to convert live_detect.py(which is the main python script that runs the program) to an exe with pyinstaller but when I run it I got the following error.
I think a lot of the python to exe converter would have trouble converting a project this size. Other than modules, there are a lot of different items needed in different directory for the neural network model and so on. Was wondering if any of you had any suggestion.
There is a program called auto-py-to-exe which creates an exe out of your program without requiring you to create a setup file. The interface is great and allows you to easily create and exe without creating a setup.py. This also allows you to package your app as a single exe, without any other files. Below is a screenshot:
You can install the program by typing into the command line:
python -m pip install auto-py-to-exe
You can run it by typing in:
auto-py-to-exe
To see more about auto-py-to-exe, please visit the PyPI page at https://pypi.org/project/auto-py-to-exe/.
I'm learning Python and don't quite have the vocabulary to describe this. However, I can't seem to save files created in Python to my Window10 computer. I discovered this while seeking a help to try to get a file to save in Pandas. I then discovered the same problem when creating a db using SQLITE3 the script seemed to have fun but no database files appeared.
Does anyone know how to fix this? FYI I've got a dual boot Ubuntu machine, I can save files via Python in Ubuntu but really need it to work on my windows machine too.
I am running python via Jupyter Notebook.
I had to make a couple changes to the code snipped that you linked in order to get this to work.
A difference between windows and linux is the file path deliminator is a forward slash:
df.to_csv("tests/ysi_test_files/filehere.csv", index = False)
If you want a hard absolute path to a file, then do something like:
df.to_csv('C://Folder//myfilename.csv', index=False)
Again, if you copy the folder path from a windows folder you will get the backslashes instead of forward slashes. You will need to change those in your code to save the file:
C:\Users\myuser\Desktop\python\
to
C:/Users/myuser/Desktop/python/
If you are running the python script from command prompt then right click on it and run as administrator should solve the issue.
This question already has answers here:
Create a single executable from a Python project [closed]
(3 answers)
Closed 3 years ago.
I wrote a script that will help a Windows user in her daily life. I want to simply send her the .exe and not ask her to install python, dlls or have to deal with any additional files.
I've read plenty of the stackoverflow entries regarding compiling Python scripts into executable files. I am a bit confused as there are many options but some seem dated (no updates since 2008) and none were simple enough for me not to be asking this right now after a few hours spent on this.
I'm hoping there's a better, up-to-date way to do this.
I looked into:
pylunch
py2exe
cx_Freeze
py2app (only for Mac)
pyinstaller
bbfreeze
but either I couldn't get them to work or couldn't understand how to get the result I need. The closest I got was with py2exe but it still gave me the MSVCR71.dll
I would appreciate a step-by-step answer as I was also unable to follow some of the tweaking answers here that require some prior understanding of how to use py2exe or some of the other tools.
I'm using Python 2.5 as one of the modules is only available for that version.
PyInstaller will create a single-file executable if you use the --onefile option (though what it actually does is extracts then runs itself).
There's a simple PyInstaller tutorial here. If you have any questions about using it, please post them...
Using py2exe, include this in your setup.py:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1}},
windows = [{'script': "YourScript.py"}],
zipfile = None,
)
then you can run it through command prompt / Idle, both works for me. Hope it helps
i would recommend going to http://sourceforge.net/projects/py2exe/files/latest/download?source=files to download py2exe. Then make a python file named setup.py.
Inside it, type
from distutils.core import setup
import py2exe
setup(console=['nameoffile.py'])
Save in your user folder
Also save the file you want converted in that same folder
Run window's command prompt
type in setup.py install py2exe
It should print many lines of code...
Next, open the dist folder.
Run the exe file.
If there are needed files for the program to work, move them to the folder
Copy/Send the dist folder to person.
Optional: Change the name of the dist folder
Hope it works!:)
I would join #Nicholas in recommending PyInstaller (with the --onefile flag), but be warned: do not use the "latest release", PyInstaller 1.3 -- it's years old. Use the "pre-release" 1.4, download it here -- or even better the code from the svn repo -- install SVN and run svn co http://svn.pyinstaller.org/trunk pyinstaller.
As #Nicholas implies, dynamic libraries cannot be run from the same file as the rest of the executable -- but fortunately they can be packed together with all the rest in a "self-unpacking" executable that will unpack itself into some temporary directory as needed; PyInstaller does a good job at this (and at many other things -- py2exe is more popular, but pyinstaller in my opinion is preferable in all other respects).
1) Get py2exe from here, according to your Python version.
2) Make a file called "setup.py" in the same folder as the script you want to convert, having the following code:
from distutils.core import setup
import py2exe
setup(console=['myscript.py']) #change 'myscript' to your script
3) Go to command prompt, navigate to that folder, and type:
python setup.py py2exe
4) It will generate a "dist" folder in the same folder as the script. This folder contains the .exe file.
you may want to see if your app can run under IronPython. If so, you can compile it to an exe
http://www.codeplex.com/IronPython
You can create executable from python script using NSIS (Nullsoft scriptable install system). Follow the below steps to convert your python files to executable.
Download and install NSIS in your system.
Compress the folder in the .zip file that you want to export into the executable.
Start NSIS and select Installer based on ZIP file. Find and provide a path to your compressed file.
Provide your Installer Name and Default Folder path and click on Generate to generate your exe file.
Once its done you can click on Test to test executable or Close to complete the process.
The executable generated can be installed on the system and can be distributed to use this application without even worrying about installing the required python and its packages.
For a video tutorial follow: How to Convert any Python File to .EXE
You could create an installer for you EXE file by:
1. Press WinKey + R
2. Type "iexpress" (without quotes) into the run window
3. Complete the wizard for creating the installation program.
4. Distribute the completed EXE.