In the previous article (https://qiita.com/akagisho/items/7dfa6304b8233b85fa13), I used Tkinter to create a sample Windows application.
This time, you can use "PyInstaller" to convert a Python script into an exe file (executable file) and execute it even on Windows without a Python execution environment. To do so.
First, pip may not work well with PyDev of Pleiades, so reinsert pip.
Download get-pip.py
from the following URL in official pip documentation and save it in a suitable folder.
Start a command prompt and run get-pip.py
in PyDev's python.
C:\pleiades\python\3\python.exe (Downloaded folder)\get-pip.py
If a message like Successfully installed pip- ~ ~
is displayed, the installation is successful.
Next, install "PyInstaller" in the PyDev environment.
Start Eclipse and open [Window]-> [Settings] from the menu.
Open [PyDev]-> [Interpreter]-> [Python Interpreter] in the left menu. Select "Python3" and click the [Manage with pip] button.
Enter "ʻinstall pyinstaller`" in "Command to execute" and click the [Execute] button. When "FINISHED" is displayed, click the [Close] button.
Now that you have PyInstaller installed, use it to exe your Python script.
Start a command prompt and run pyinstaller.exe
. At this time, specify the Python script you want to exe in the argument.
Execution example
cd C:\pleiades\workspace\testproj1
C:\pleiades\python\3\Scripts\pyinstaller.exe C:\pleiades\workspace\testproj1\test1.py --onefile --noconsole
If all goes well, an exe file will be created in the dist
folder under the current directory of the command prompt (C: \ pleiades \ workspace \ testproj1
in the above example).
Double-click the generated exe file to execute it. The application starts after a while.
Recommended Posts