Creating exe from a Python Directory - python

so I finished a project in python and now I wanna transfer the whole project into exe.
I have a couple directories in the project which makes it look like so :
My Main is in ServerStart and it has dependencies from all the other files in the directories.
how can I create 1 exe file that will run it all?
I tried using pyinstaller and failed miserable.
the command I used(already inside the projects directory)
pip install pyinstaller
cd ServerStart
pyinstaller --onefile ServerMain.py
Am I missing on something ? it just creates an exe that on click -and closes immediately , when I used pause in the batch , it seemed like the program didn't even start running .
python script

Try using auto-py-to-exe. I have used it once and it seemed to work fine for me.

Related

i want to compile .py to .exe

i want to compile .py to .exe. But when i do so the exe files is too big. Is there a solution??
i want the exe to be a smaller
i know that python was not meant to be compiled, executables made from python are bound to be large
, but the problem is i have learnt python like 3 years, and now i want to make apps/games for windows. i can't just install python on every device??
i want to make it small
i learnt that there is something called executable-packing??
using tools like crinkler
how can we do that with python
with pyinstaller or cx_freeze
Python 3.6 is supported by PyInstaller.
Open a cmd window in your Python folder (open a command window and use cd or while holding shift, right click it on Windows Explorer and choose 'Open command window here'). Then just enter
pip install pyinstaller
And that's it.
The simplest way to use it is by entering on your command prompt
pyinstaller file_name.py
For more details on how to use it, take a look at link

Sending a PyCharm project to someone

I just finished working on a PyCharm project (using python 3.7), which uses libraries downloaded using PyCharm's built in functionality. I just want to send this project to my boss so that he can simply run it by clicking on it, without having to go through downloading PyCharm and downloading the applicable packages. Please tell me that there is a way to do this. Thank you
if you want to convert your python project to a program exucutable in windows you can use the library pyinstaller.
install the library:
pip install pyinstaller
then in the path of the project,open a command console and type the following commands.
if you want the executable in one file(slower start):
pyinstaller.exe --onefile --windowed --icon="your_icon_file".ico "your_python_script".py
if you want the executable in one folder(faster start):
pyinstaller.exe --onedir --windowed --icon="your_icon_file".ico "your_python_script".py
this wil create a folder call "dist" where your .exe will be,
pd: whith the --onedir command you will see all your dependencies in that folder, if you have a simple script you can use the first option.
Link to the pyinstaller documentation:https://pypi.org/project/pyinstaller/
You could solve this issue by converting the .py file to an executable file or .exe file....
Hopefully it helped..thx
A simple way to that would be sharing it on github with a requirements.txt file containing all the dependencies which then can be installed using python -m pip install -r requirements.txt.
Or You can use pyinstaller --onefile <yourfile.py> to create a .exe file which could be run without any requirements on windows.

How to set up PyInstaller in PyCharm for a project using External Tools inside venv?

I have a project in PyCharm with multiple Python files, as well as some text files, which I want to export into .exe via PyInstaller (I'm on Win 7). The project uses some external modules installed inside venv via pip (PyInstaller is one of them).
I want to keep things simple and not use any modules outside venv in the build, for obvious reasons. However, when I try to execute the PyInstaller tool on the project folder, I get a permission error: PermissionError: [Errno 13] Permission denied. Using PyInstaller on the main.py inside the project builds it just fine at first glance, but running the .exe in cmd shows an error loading Python DLL. How do I do it right? Something tells me the spec should be created beforehand to include all files and modules used in the project.
To answer the question in the title, the Arguments you specify in PyCharm are passed to pyinstaller.exe when you execute the tool. So it should be the path to main.py or the path to your .spec file, not $FilePath$ which is a macro that gets replaced by the file that is currently open in PyCharm.
You should definitely have a .spec file, that is committed to version control. This makes your PyInstaller builds more consistent, and allows others to reproduce them easily. See https://pyinstaller.readthedocs.io/en/stable/spec-files.html

Pyinstaller: OSError: Cannot load AutoItX from path

So I have a program and whenever I start it from the command line it works totally fine. What I need now is an Executable and therefor I tried to do it with pyinstaller, which analyzes normally automatically which modules have been imported and it works fine with all of the modules except for autoit. The way I import it looks like that:
import autoit
So I tried to make an executable by following command:
pyinstaller --onefile ./rocketupload.py
Which gave me this Error (Excuse me, that I have to make a screenshot, but the window was open for a second and closed immediately afterwards, so I was not able to copy and paste it here):
I was able to create a functioning exe by copying the autoit dll to the path mentioned in the Error, but that is just a temporary solution, since I want the executable to be running not only on my PC.
I've also tried this one without succes:
pyinstaller --hidden-import=autoit --onefile --paths c:\users\semjo\appdata\local\programs\python\python37\lib\site-packages\autoit\lib .\rocketupload.py
So the problem here is that the autoit module does not get copied from pyinstaller so It cannot run the executable as inteded. But I dont know how to solve it, so that the exe can run as intended. Hope you can help me here, tried to find a solution for hours now...
I had also encountered the same problem and i solved it by implementing the follows:-
Re-installed the pyinstaller module using the latest installer available in github i.e. pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
Re-created the executable package by running the command i.e. pyinstaller --hidden-import=selenium --hidden-import=autoit your [python_file.py]
Copied the installed module i.e. autoit's folder from my PC's directory (C:\Users\\AppData\Local\Programs\Python\Python37\Lib\site-packages) and pasted it inside the [python_file] folder in dist folder which was generated by pyinstaller.
To test the solution, i re-run the generated .exe file in command prompt. Hope this help.
hiddenimports = [ "autoit.init", "autoit.autoit", "autoit.control",
"autoit.process", "autoit.win" ]
datas = [
[
"C:\\Python27\\lib\\site-packages\\autoit\\lib\\AutoItX3_x64.dll",
"autoit\\lib"
]
]
https://raveendran.wordpress.com/2012/06/15/how-to-installregister-autoitx3-dll/
Do this two process your issue will resolve. It resolved me.

How do I run a Python 3.5 program that uses Tkinter on a computer without Python installed?

I have coded a program in Python 3.5 that uses the Tkinter import. I'm trying to figure out a way to run it on computers that don't have Python. First I tried freezing it but I haven't been able to because none of the freezing tools I found support Python 3.5. Then I tried possibly using a online idle but I couldn't find any that support Tkinter. I would prefer to be able to get a .exe file or something similar but if I could run it online that would be good too any ideas?
EDIT
So I have now successfully downloaded PyInstaller using pip. My current problem is when I type this into the console: pyinstaller.exe --onefile --windowed Finder.py
I get this error: 'pyinstaller.exe' is not recognized as an internal or external command,
operable program or batch file.
EDIT
I have now found the pathway to pyinstaller.exe. Now when I try to use it it says Access is denied.
I finally figured it out after about three days of work. Fist I downloaded PyInstaleller in the zipped form and extracted it. Then I put my program in the PyInstaller folder. Then I opened a regular command prompt. I then typed cd then the location of the PyInstaller folder. Finally I typed pyinstaller.py --one file --windowed program.py. Then when I went into the PyInstaller folder there was a folder called program with the .exe file in the dist folder. Thanks everyone for all of your help!
You can use pyinstaller to do that. I think its work fine on linux em linux.
Another option is use py2exe.
Try pyinstaller -F -w Finder.py as the command or you could check out CxFreeze.

Categories