Create exe file from script using Pyinstaller in Anaconda environment - python

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!

Related

Building one file eel python aplication with pyinstaller

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?

Pyinstaller - invalid syntax

I am trying to use pyinstaller to package my script into an exe.
All sources indicate that the correct syntax is: pyinstaller FullClientCreator.py
When I issue this command, I get a syntax error:
pyinstaller FullClientCreator.py
File "C:\Users\DAVIDM~1\AppData\Local\Temp/ipykernel_7368/3509825318.py", line 1
pyinstaller FullClientCreator.py
^
SyntaxError: invalid syntax
I also tried it with the full path for the file, and I still get the same error:
pyinstaller "D:\Projects\ZZNew Client CreatorZZ\FullClientCreator.py"
File "C:\Users\DAVIDM~1\AppData\Local\Temp/ipykernel_7368/546891165.py", line 1
pyinstaller "D:\Projects\ZZNew Client CreatorZZ\FullClientCreator.py"
^
SyntaxError: invalid syntax
I am at a complete loss as to why this could be, so if anyone has any suggestions, I would greatly appreciate them.
Try another shell
I dont know which shell are you using but if you're using python shell sometimes its not working for python shell so try it on your cmd
pyinstaller --onefile file.py

Q: Python script into ececutable NOT WORKING (pyinstaller / cx_Freeze)

I tried to convert a python script called table.py to .exe
The scripts imports openpyxl, pandas, dataframe_image
I've tried using the modules in the title as so:
pyinstaller: I ran: pyinstaller --onefile -windowed table.py . When I click the executable there's a popup message saying Failed to execute script table
cx_Freeze: I ran python setup.py build_exe
it printed error: The baseline image directory does not exist. This is most likely because the test data is not installed. You may need to install matplotlib from the source to get the test data.
so I followed the answer here and ran:
pip install "numpy<1.18.3" "pillow<7"
python setup.py build_exe --excludes=matplotlib.tests,numpy.random._examples
and It poped up this message:
Anyone got any ideas on how to proceed now?

Pyinstaller : Failed to create process when packaging a file

I am using Pyinstaller to package an app that I made. And when I type :
C:\Users\Hung Truong\Desktop\Python>pyinstaller.exe --onefile --windowed file.py
It gives the error:
failed to create process.
How can I fix this ? Any help is appreciated !
In pyinstaller-script.py
!c:\program files\python\python35-32\python.exe
alter this line with below code:
!"c:\program files\python\python35-32\python.exe"
I had the same issue so I checked the file
C:\Python27\Scripts\pyinstaller-script.py
and there was an old python path which when I installed python installer
C:\Python27\python.exe
But later I renamed python.exe --> python2.exe, so I just changed the path
C:\Python27\python.exe --> C:\Python27\python2.exe
in file
C:\Python27\Scripts\pyinstaller-script.py
and it worked perfectly.

Importing modules with python

I'm working with python 2.7 (32-bit) on Windows Vista. I downloaded some libraries including numpy, scipy, and pygame. When I try to import these modules the output says
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
ImportError: No module named numpy
I can find these modules in my python folders but for some reason it doesn't want to recognize it or some thing. (I made sure the file were compatible before downloading.)
Each package should contain a setup.py file. Run this with the command python setup.py install
For more information:
http://www.scipy.org/Installing_SciPy/Windows
http://pygame.org/install.html
"Everytime I run the command "python setup.py install" in the python shell it says SyntaxError: invalid syntax "
Please create a folder where you unzip the "numpy.zip" file, say the folder name is "c:\numpy"
Open a MS-DOS terminal (as described here : http://en.wikipedia.org/wiki/Command-line_interface), and type :
cd c:\numpy
python setup.py config
python setup.py install
This will set up the needed files in the correct folders for your python.
Enjoy !
To properly install this module:
In the Windows search bar (START MENU) type Command Prompt
Right-click on the Command Prompt icon (DO NOT go to cmd)
Click Run as Administrator
in the COMMAND PROMPT (DO NOT open cmd) type:
pip install numpy
This will install that module.
NOTE: If you are NOT in admin mode, you will get a message saying a fatal error has been raised.

Categories

Resources