2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[pyinstaller] or [py2exe] でpyファイルをEXE化 (2022-01-22)

Posted at

前回、Windows10環境に、Python3をインストールしたので、今回は、exe化をやってみました。

前回の記事:

pyinstaller をインストール

イメージ7598.jpg

exe化テスト

シンプルにprint文のみでとりあえずやってみます。

Hello-Python.py
# -*- coding: utf-8 -*-
import sys
print("Hello,Python!")

一応、実行確認

イメージ7600.jpg

pyinstaller コマンドでEXEファイル作成

pyinstaller (ファイル名) --onefile

で、EXEファイルが出来るようなので作ってみます。

$ pyinstaller Hello-Python.py --onefile

イメージ7601.jpg

「dist」フォルダ内に、「Hello-Python.exe」が作成されていました。

イメージ7602.jpg

exeファイル実行テスト

イメージ7603.jpg

py2exeでexe化

py2exeの方もやってみました

pipでインストール

$ pip install py2exe

setup.pyを作成

setup.py
from distutils.core import setup
import py2exe

setup(console=['Hello-Python.py'])

実行

$ python setup.py py2exe

イメージ7604.jpg

実行後、distフォルダ内にHello-Python.exeが作成されるようです。

起動
イメージ7605.jpg

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?