I have a simple scipt that gives me the time to a specific date and i'm using pyinstaller with this command to convert it to a .exe file to give to my friend:
pyinstaller --onefile --windowed "D:/Documents/code/own/python/sages_birthday/time_till_meetup.py"
When i then try to execute the created file i get this window as an error:
I have made a file with --console instead of --windowed to try and get more information, but i didn't even get the error to pop up or any other information.
Step 1: Add Python to Windows Path
Step 2: Open the Windows Command Prompt
Step 3: Install the Pyinstaller Package
pip install pyinstaller
Step 4: Save your Python Script
Step 5: Create the Executable using Pyinstaller
cd followed by the location where your Python script is stored
Step 6: pyinstaller --onefile pythonScriptName.py
Step 7: Run the Executable
Few additional files got created at that location. To find the executable
file, open the dist folder:
Related
After building distributable binary with PyInstaller
python.exe -m eel --onefile c:\Users\Darek\PycharmProjects\eelTest\web\ c:\Users\Darek\PycharmProjects\eelTest\eelTest.py
When I try run app I got this error
Failed to extract C:\Users\Darek\PycharmProjects\eelTest\web\main.html: failed to open target file!
fopen: Invalid argument
How to fix it?
Suppose you wrote a python code which does certain operations (taking in excel data, perform analysis, giving out a excel data with graphs). You can do it because you have Python installed on your laptop. But how does your colleague work with the same code, if he want to use it?
Step 1: Save the file, which you want make as an executable as filename.py in directory C:\Users\yourname
Step 2: Create an environment using command prompt so that the executable file can be made within the environment
C:\Users\yourname> mkdir Envirornments
Step 3: Go to the environment by typing following in command prompt: C:\Users\yourname> cd Environments
Next thing will appear: C:\Users\yourname\Environments
Step 4: Create a new project environment, type following:
C:\Users\yourname\Environments>virtualenv project2_env
Step 5: Give project a name into the environment, type following:
C:\Users\yourname\Environments>cd project2_env
Step 6: Activate the project, type following:
C:\Users\yourname\Environments\project2_env>Scripts\activate
Step 7: Install required packages for your python file, including pyinstaller:
(project2_env)C:\Users\yourname\Environments\project2_env>pip install package1
(project2_env)C:\Users\yourname\Environments\project2_env>pip install package2
(project2_env)C:\Users\yourname\Environments\project2_env>pip install package3
(project2_env)C:\Users\yourname\Environments\project2_env>pip install pyinstaller
Step 8: Copy paste the python file from step 1 to the environments folder.
Step 9: Create the executable file, type following:
(project2_env)C:\Users\yourname\Environments\project2_env> pyinstaller — onefile -w filename.py
Anaconda will make an executable file with the filename in the folder 'dist'. The file has python image on it and usually the largest size within the folder.
If you double click the file, it will start running.
I wrote a simple code in python/pygame, and the game was running fine in both sublime text and cmd, but when I tried to make it a exe file pyinstaller --onefile version2.py, I got an error and I don't know what is the problem ?
Well bro, I don't know if I will be helpfull to you know after 6 days, I am having 2 solutions for you which worked for me today.
Disable Antivirus OR put that folder in which you are building app.exe to Exception, like I have done below [Mandatory Process].
Dont' run pyinstaller command from the directory where app.py application is present.
a) Get out from that directory/folder
b) Create new directory/folder
c) Enter that directory and start cmd in that directory/folder by pressing (shift + MouseRightClick )
d) And then run the command
pyinstaller --name "MyApp" "python script file path of which you want to create .exe file"
Where "MyApp" is the name which you want to give to the file after it is build successfully
For Example
pyinstaller --name "FileRenamer" "G:\data\python\Project\Bunch File Renamer\rename.py"
Try to disable the anti-virus, that worked for me
I want to create exe file in Anaconda environment using Pyinstaller.
First, I have successfully installed Pyinstaller using this code:
conda install -c conda-forge pyinstaller
Then I also have converted my ipynb file to py file using "Download as".
Now, when I tried my py code using this code:
python Jumlah.py
I got his error:
File "<ipython-input-7-a5108a3cc2af>", line 1
python Jumlah.py
^
SyntaxError: invalid syntax
An when I run Pyinstaller using this code:
pyinstaller --onefile Jumlah.py
I got the same error:
File "<ipython-input-8-405d6dae7a75>", line 1
pyinstaller --onefile Jumlah.py
^
SyntaxError: invalid syntax
So, how can I fix this error?
Your problem is that after downloading the jupyter notebook as .py, your file.py contains lines like "get_ipython().run_line_magic('matplotlib', 'inline')".
You have to delete them first!
I downloaded pyinstaller and pywin32 and placed both in the Python32-35 folder
I then put a copy of the gui program(Homework.py) I coded into the Scripts folder that is located in the previous folder
Now I when I open a cmd window and enter the code
pyinstaller--onefile --windowed Homework.py
I am receiving the error in cmd saying
'pyinstaller--onefile' is not recognized as an internal or external command,
operable program or batch file.
use this command to call the module directly:
python -m PyInstaller --onefile --windowed --name="fileName" Homework.py