<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tkinter | アリッシアの朝</title>
	<atom:link href="https://alicia-ing.com/en/tag/tkinter/feed/" rel="self" type="application/rss+xml" />
	<link>https://alicia-ing.com/en</link>
	<description></description>
	<lastBuildDate>Thu, 30 Jan 2025 13:15:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia-32x32.webp</url>
	<title>Tkinter | アリッシアの朝</title>
	<link>https://alicia-ing.com/en</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Python】exe化の方法と各ライブラリは商用利用可能なのか</title>
		<link>https://alicia-ing.com/en/programming/python/exe-file/</link>
					<comments>https://alicia-ing.com/en/programming/python/exe-file/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Thu, 30 Jan 2025 12:52:40 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Tkinter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8368</guid>

					<description><![CDATA[Python is a highly versatile programming language capable of much more than just powering modern artificial intelligence. It is widely used in fields such as data science, IoT and hardware control, as well as game and web development. Moreover, Python is a popular choice among universities and research institutions due to its flexibility and powerful [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Python is a highly versatile programming language capable of much more than just powering modern artificial intelligence. It is widely used in fields such as data science, IoT and hardware control, as well as game and web development. Moreover, Python is a popular choice among universities and research institutions due to its flexibility and powerful features.</p>



<p>However, unlike front-end languages like HTML, CSS, and JavaScript, Python needs to be installed on your computer to run programs. (<em>You can download it from the official Python website.</em>)</p>



<p>While platforms like Jupyter Notebook and Google Colab allow you to experiment with data science and machine learning directly in your web browser, they are limited in scope. For example, applications involving Tkinter or game development cannot be executed in these environments.</p>



<p>Therefore, to fully leverage Python’s capabilities, you need to install it on your personal computer. Additionally, if you provide Python source code to someone who does not have Python installed, they will not be able to run it.</p>



<p>However, you can solve this issue by converting your Python code into an executable (.exe) file. This enables users without Python installed to run your application seamlessly. In other words, you can distribute and even sell your custom software to a broader audience.</p>



<p>One of Python built in GUI libraries, <strong>Tkinter</strong>, pairs exceptionally well with the process of creating executable files.</p>



<p>Several tools can convert Python scripts to executable files, including PyInstaller, py2exe, Nuitka, and cx_Freeze. However, each of these libraries comes with different licensing conditions, so you must verify whether they permit commercial use.</p>



<p></p>



<p>In this article, we will guide you through the process of converting Python files into executable (.exe) applications.</p>



<p></p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text"></span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Tkinterについて知りたい。</li>



<li>Pythonをexe化する方法を知りたい。</li>



<li>Pythonで作ったソフトを配布・販売したい。</li>



<li>シェルを使わずにPythonを動かしたい。</li>



<li>pynstallerのインストール方法を知りたい。</li>
</ul>
</div></div>



<div id="rtoc-mokuji-wrapper" class="rtoc-mokuji-content frame3 preset1 animation-none rtoc_open default" data-id="8368" data-theme="Cocoon Child">
			<div id="rtoc-mokuji-title" class=" rtoc_left">
			<button class="rtoc_open_close rtoc_open"></button>
			<span>目次</span>
			</div><ol class="rtoc-mokuji decimal_ol level-1"><li class="rtoc-item"><a href="#rtoc-1">Tkinterとは</a></li><li class="rtoc-item"><a href="#rtoc-2">exe化・exeファイルとは</a></li><li class="rtoc-item"><a href="#rtoc-3">MacOSでexeファイル実行する方法</a></li><li class="rtoc-item"><a href="#rtoc-4">exe化のメリット</a><ul class="rtoc-mokuji mokuji_ul level-2"><li class="rtoc-item"><a href="#rtoc-5">Python環境が構築をされていないPCで起動</a></li><li class="rtoc-item"><a href="#rtoc-6">Pythonの知識不要</a></li><li class="rtoc-item"><a href="#rtoc-7">実行速度の向上</a></li></ul></li><li class="rtoc-item"><a href="#rtoc-8">exe化するライブラリ</a><ul class="rtoc-mokuji mokuji_ul level-2"><li class="rtoc-item"><a href="#rtoc-9">PyInstaller</a></li><li class="rtoc-item"><a href="#rtoc-10">py2exe</a></li><li class="rtoc-item"><a href="#rtoc-11">Nuitka</a></li><li class="rtoc-item"><a href="#rtoc-12">cx_Freeze</a></li></ul></li><li class="rtoc-item"><a href="#rtoc-13">各種ライブラリの特徴</a></li><li class="rtoc-item"><a href="#rtoc-14">exe化の手順</a><ul class="rtoc-mokuji mokuji_ul level-2"><li class="rtoc-item"><a href="#rtoc-15">コマンドプロンプト起動・PyInstallerをインストール</a></li><li class="rtoc-item"><a href="#rtoc-16">Python　exe化</a></li></ul></li><li class="rtoc-item"><a href="#rtoc-17">まとめ</a></li></ol></div><h2 id="rtoc-1"  class="wp-block-heading">Tkinterとは</h2>



<figure class="wp-block-image aligncenter size-large"><img fetchpriority="high" decoding="async" width="1024" height="533" src="https://alicia-ing.com/wp-content/uploads/2023/05/Tkinter-1024x533.webp" alt="" class="wp-image-1940" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/Tkinter-1024x533.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/05/Tkinter-300x156.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/05/Tkinter-768x400.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/Tkinter-1536x800.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/05/Tkinter.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Tkinterは、<strong>Pythonの標準ライブラリ</strong>で、<strong>GUIアプリケーションを作成するためのツールキット</strong>です。<br>Tkinterは、Tcl/TkをラップしてPythonから利用できるようにしたもので、<strong>Pythonのクロスプラットフォーム性を維持</strong>しながら、シンプルで使いやすいGUIアプリケーションを作成できます。</p>



<p>Tkinterは、ボタン、ラベル、テキストボックス、スクロールバー、メニューなどの<strong>ウィジェットを提供</strong>し、これらを自由に配置してGUIアプリケーションを構築することができます。<br>また、ウィンドウのサイズや色、フォントなどのカスタマイズも可能です。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>tkinterのボタンについてまとめています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/tkinter-button/" title="【Python】Tkinterボタン作成、関数処理(def)" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2022/12/tkinter-button.webp" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">【Python】Tkinterボタン作成、関数処理(def)</div><div class="blogcard-snippet external-blogcard-snippet">PythonのTkinterでGUIボタンを構築する方法を紹介します。標準ボタンを作成したり配置したり、さらに色を指定し...</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com/programming/python/tkinter-button/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">alicia-ing.com</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>tkinterのラベルについてまとめています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/tkinter-label/" title="【Python】Tkinterを使ったラベル作成の方法と使い方、カスタマイズの解説" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://alicia-ing.com/wp-content/uploads/2022/12/tkinter-label.webp" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">【Python】Tkinterを使ったラベル作成の方法と使い方、カスタマイズの解説</div><div class="blogcard-snippet external-blogcard-snippet">ラベルの配置はpack()、grid()、place()３つのメソッドがあり、その他、sideオプションやanchorオ...</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com/programming/python/tkinter-label/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">alicia-ing.com</div></div></div></div></a>
</div>



<p>Tkinterは、Pythonの標準ライブラリに含まれているため、<strong>Pythonをインストールすると自動的に使用できます</strong>。初心者から上級者まで、幅広いレベルのプログラマーにとって使いやすいGUI開発ツールキットです。</p>



<p>またTkinterは、<strong>画面遷移（画面切り替え）</strong>を使えば、より本格的なアプリを作成することができます。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>tkinterの画面遷移を使って、カウントダウンタイマーを作成しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/change_screen/" title="【Python】Tkinterの画面遷移（切り替え）複数画面処理" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/change_screen.webp" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">【Python】Tkinterの画面遷移（切り替え）複数画面処理</div><div class="blogcard-snippet external-blogcard-snippet">Tkinterの複数ウィンドウを画面遷移するには、pack_forget()メソッドを使います。ボタンでクリックすると表...</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com/programming/python/change_screen/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">alicia-ing.com</div></div></div></div></a>
</div>



<p>公式サイト：「<a target="_self" href="https://docs.python.org/ja/3/library/tkinter.html#module-tkinter" title="tkinter --- Tcl/Tk の Python インターフェース">tkinter &#8212; Tcl/Tk の Python インターフェース</a>」</p>



<h2 id="rtoc-2"  class="wp-block-heading">exe化・exeファイルとは</h2>



<figure class="wp-block-image aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="533" src="https://alicia-ing.com/wp-content/uploads/2023/05/exe-1024x533.webp" alt="" class="wp-image-1941" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/exe-1024x533.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/05/exe-300x156.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/05/exe-768x400.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/exe-1536x800.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/05/exe.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>.exeファイルとは、Windowsオペレーティングシステムで実行可能なプログラムファイルです。<br>「exe」は「executable」の略で、コンピュータで実行される指示や命令を含むファイルです。</p>



<p>一般的に、exe化は、Windows用のプログラムを開発する際に使用されます。開発者は、プログラムをexeファイルに変換することで、ユーザーがソフトウェアを簡単にインストールし、Windows上でアプリケーションを実行できるようにします。</p>



<p>また、exeファイルは、様々なセキュリティ機能を実装することができ、不正なコードの実行を防止することもできます。</p>



<p>※参考ページ：「<a target="_self" href="https://wa3.i-3-i.info/word12258.html" title="" class="broken_link">exeファイルとは</a>」</p>



<h2 id="rtoc-3"  class="wp-block-heading">MacOSでexeファイル実行する方法</h2>



<figure class="wp-block-image aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="533" src="https://alicia-ing.com/wp-content/uploads/2023/05/exe-for-mac-1024x533.webp" alt="" class="wp-image-1942" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/exe-for-mac-1024x533.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/05/exe-for-mac-300x156.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/05/exe-for-mac-768x400.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/exe-for-mac-1536x800.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/05/exe-for-mac.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>exeファイルはWindows用のプログラム拡張子なので、<strong>Macでは動作</strong>しません。<br>ただし、Macでも、exeファイルを起動させる方法があります。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-tips block-box">
<ul class="wp-block-list">
<li>「Wine」をインストールしてexeファイルを開く。</li>



<li>「VirtualBox」や「BootCamp」などを利用してWindowsの仮想環境を構築。</li>
</ul>
</div>



<p>参考ページ:「<a target="_self" title="macOSでEXEファイルを実行する方法と消えたEXEファイルを復元する方法" href="https://4ddig.tenorshare.com/jp/mac-recovery-solutions/open-and-recover-exe-files-on-mac.html">macOSでEXEファイルを実行する方法と消えたEXEファイルを復元する方法</a>」</p>



<p>「<a target="_self" title="Wine" href="https://www.winehq.org/">Wine</a>」はmacOSやLinuxをUnix系オペレーティングシステム上でWindowsアプリケーションを実行するためのプログラムで、Windowsアプリケーションが依存するAPI（Application Programming Interface）を再現し、Windows以外のプラットフォームでも動作させることができます。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="1024" height="576" src="https://alicia-ing.com/wp-content/uploads/2023/05/wine-Sc.webp" alt="" class="wp-image-1799" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/wine-Sc.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/05/wine-Sc-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/05/wine-Sc-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/wine-Sc-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/05/wine-Sc-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/05/wine-Sc-320x180.webp 320w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>また、「<a target="_self" href="https://www.virtualbox.org/" title="VirtualBox">VirtualBox</a>」や「<a target="_self" href="https://support.apple.com/ja-jp/HT201468" title="BootCamp">BootCamp</a>」はどちらも仮想のWindows環境を構築します。</p>



<p>しかし、個人的な意見としては、macOSでWindowsの仮想環境を起動させるために、<br>自分自身で下調べをして動作させるという<strong>リスクが伴います</strong>。<br>また、CPUやメモリに負荷がかけて、内蔵ストレージ容量も取ります。</p>



<p>macOSでexeファイルを稼働させることにメリットが見つからないので、<br><strong>macOSでWindowsの仮想環境を構築するのは控え方が良い</strong>です。</p>



<h2 id="rtoc-4"  class="wp-block-heading">exe化のメリット</h2>



<figure class="wp-block-image aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="533" src="https://alicia-ing.com/wp-content/uploads/2023/05/merit-1024x533.webp" alt="" class="wp-image-1946" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/merit-1024x533.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/05/merit-300x156.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/05/merit-768x400.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/merit-1536x800.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/05/merit.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Pythonのexe化することで以下のようなメリットがあります。</p>



<ul class="wp-block-list">
<li>PythonをインストールしていないPCでも手軽に実行できる。</li>



<li>ユーザーにPythonの知識がなくても実行できる。</li>



<li>実行速度が向上する場合がある。</li>



<li>配布が容易になる。</li>
</ul>



<h3 id="rtoc-5"  class="wp-block-heading">Python環境が構築をされていないPCで起動</h3>



<p>Pythonは「<a target="_self" href="https://jupyter.org/">jupyter</a>」や「<a target="_self" href="https://colab.research.google.com/?hl=ja" title="Google Colaboratory">Google Colaboratory</a>」のようなにブラウザ上でPythonを実行させることができて便利ですが、これらのプラットフォームに依存しているため、<strong>「Tkinter」が使えない</strong>といった注意点があります。<br>したがって、大型のPythonスクリプトを実行させることはあまり向いていません。<br>また、前述したようにPythonを動かすには基本的に<strong>Pythonをインストール</strong>しなければいけません。<br><br>さらに、Pythonを日常的に扱う人は、既にPCへPythonの環境を構築しているかと思いますが、普段Pythonを使わない人にスクリプトを渡しても、<strong>受け取った人のPCにPythonがインストールされていない</strong>ことは十分に考えられます。<br><br>しかし、exe化することでこのようなこのような懸念は解消させます。</p>



<p>スクリプトをexe化することでPCにPythonをインストールする必要がなくなり、手軽に実行できるようになります。したがって、Python環境を構築していない受け取った人もスクリプトを動かすことができます。</p>



<h3 id="rtoc-6"  class="wp-block-heading">Pythonの知識不要</h3>



<p>Pythonは、「Tkinter」をはじめ標準ライブラリだけでも豊富な機能を持っていますが、さらに、Webアプリケーション開発のためのDjangoやFlask、データ分析のためのNumPyやpandas、機械学習のためのTensorFlowやPyTorchなど、さまざまな分野で使える<strong>豊富なライブラリ</strong>が利用できます。</p>



<p>しかし、これほど豊富なライブラリを抱えていると、どのライブラリがどんな場面で使えばよいかと<strong>知識が必要</strong>になり、これらもPythonと同様に<strong>インストールが必須</strong>となります。</p>



<p>PythonをVScodeやコマンドプロンプトなどのシェルから動作させるとき、実行するコマンドを入力しなければいけません。exe化によって、プログラムを配布する場合も、Pythonのインストールや環境設定など難しいコマンド入力をユーザーに求めることがないため、利用者の負担が軽減されます。</p>



<h3 id="rtoc-7"  class="wp-block-heading">実行速度の向上</h3>



<p>Pythonはインタープリタ言語であるため、実行速度が遅いという欠点があります。しかし、exe化することで、Pythonのスクリプトをバイトコードに変換し、それを実行することができるようになります。そのため、実行速度が向上する場合があります。</p>



<h4 class="wp-block-heading">UdemyでPythonを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fpython-beginner%2F">現役シリコンバレーエンジニアが教えるPython 3 入門 + 応用 +アメリカのシリコンバレー流コードスタイル</a><br>Pythonをインストールから環境設定、基本文法が学習<br>さらに暗号化、インフラ自動化、非同期処理についても学べます。<br><strong>Pythonを基礎から応用まで学びたい人</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Flearning-ai%2F">みんなのAI講座 ゼロからPythonで学ぶ人工知能と機械学習 【2024年最新版】</a><br>機械学習ライブラリで文字認識や株価分析などを行う。<br><strong>人口知能やニューラルネットワーク、機械学習を学びたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fdatascience365%2F">【世界で55万人が受講】データサイエンティストを目指すあなたへ〜データサイエンス25時間ブートキャンプ〜</a><br>統計分析、機械学習の実装、ディープラーニングの実装を学習。<br><strong>データサイエンティストになりたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fpython_tkinter_master%2F">0から始めるTkinterの使い方完全マスター講座〜Python×GUIの基礎・応用〜</a><br>TkinterのGUIを作成から発展的な操作までアプリ実例を示して学習。<br><strong>アプリ開発したい人</strong>におすすめ。</li>
</ul>
</div>



<h2 id="rtoc-8"  class="wp-block-heading">exe化するライブラリ</h2>



<figure class="wp-block-image aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="533" src="https://alicia-ing.com/wp-content/uploads/2023/05/Library-1-1024x533.webp" alt="" class="wp-image-1947" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/Library-1-1024x533.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/05/Library-1-300x156.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/05/Library-1-768x400.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/Library-1-1536x800.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/05/Library-1.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Pythonをexe化するライブラリは前述したようにPyInstaller、py2exe、Nuitka、cx_Freezeなどが存在します。</p>



<p>これらのライブラリは、Pythonスクリプトを実行可能ファイルに変換するための異なる方法を提供しています。選択するライブラリは、必要な機能や環境に合わせて選択する必要があります。</p>



<h3 id="rtoc-9"  class="wp-block-heading">PyInstaller</h3>



<p>PyInstallerは、最も王道なexe化するライブラリで、Pythonスクリプトを単一の実行可能ファイルに変換するためのツールです。多くの依存関係を解決し、パッケージを作成するために必要なすべてのファイルを含む実行可能ファイルを作成します。<br>また、新しいPythonのバージョンにも対応しています。</p>



<p>インストールするには、コマンドプロンプトで次のように入力が必要です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>pip install pyinstaller</code></pre></div>



<p>公式サイト：「<a target="_self" title="PyInstaller Manual" href="https://pyinstaller.org/en/stable/">PyInstaller Manual</a>」</p>



<h4 class="wp-block-heading">PyInstallerは商用利用可能？</h4>



<p>PyInstallerをインストールしたもの配布や販売（商用利用）に使用してよいのか気になっているかと思います。</p>



<p>以下に、PyInstallerのライセンスの<strong>一部を抜粋して引用</strong>しています。<br>詳細は引用先のURLから各自で確認してください。</p>



<p><strong>PyInstallerを使用して商用アプリケーションをバンドルすることができます。</strong><br>バンドルとは、複数の製品やサービスを一括してパッケージ化して提供することです。<br>例えば、PCやスマートフォンはOSとアプリのソフトウェアがあります。</p>



<p>PyInstallerソースコードの変更も可能です。<br>ただし、GPLライセンスの条件の下で行う必要があります。<br><strong>変更を配布する場合は、GPL条項の下で配布</strong>しなければいけません。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>You may use PyInstaller to bundle commercial applications out of your<br>source code.</p>



<p>The executable bundles generated by PyInstaller from your source code<br>can be shipped with whatever license you want, as long as it complies with the licenses of your dependencies.</p>



<p>You may modify PyInstaller for your own needs but changes to the<br>PyInstaller source code fall under the terms of the GPL license. That is, if you distribute your modifications you must distribute them under GPL terms.</p>
<cite><a target="_self" href="https://pyinstaller.org/en/v5.10.1/license.html" title="PyInstaller-License">PyInstaller-License</a></cite></blockquote>



<h3 id="rtoc-10"  class="wp-block-heading">py2exe</h3>



<p>Pythonスクリプトが依存するすべてのライブラリを含む単一の実行可能ファイルを作成します。ただし、Linux、Mac OS Xなどのプラットフォームには非対応で、Windowsにのみ対応しています。また、一部の非搭載ライブラリとの統合に問題がある場合があります。</p>



<p>インストールするには、コマンドプロンプトで次のように入力が必要です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>pip install py2exe</code></pre></div>



<p>公式サイト：「<a target="_self" href="https://www.py2exe.org/" title="py2exe">py2exe</a>」</p>



<h3 id="rtoc-11"  class="wp-block-heading">Nuitka</h3>



<p>Pythonスクリプトを高速なC言語のコードに変換するためのツールです。<br>ゆえに、他のライブラリより実行が高速であることが特徴です。</p>



<p>ただし、すべてのPython機能をサポートしているわけではありません。<br>また、一度C言語でコンパイルするため、exeファイルを作成するまでに時間がかかります。</p>



<p>インストールするには、コマンドプロンプトで次のように入力が必要です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>pip install nuitka</code></pre></div>



<p>公式サイト「<a target="_self" title="Nuitka the Python Compiler" href="https://www.nuitka.net/">Nuitka the Python Compiler</a>」</p>



<h4 class="wp-block-heading">Nuitkaは商用利用可能？</h4>



<p>NuitkaのライセンスはApache License 2.0です。<br>このライセンスによると、商用利用可能です。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><strong><a>2. Grant of Copyright License</a></strong>. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.</p>



<p><strong><a>3. Grant of Patent License</a></strong>. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.</p>



<p></p>
<cite><a target="_self" href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a></cite></blockquote>



<h3 id="rtoc-12"  class="wp-block-heading">cx_Freeze</h3>



<p>cx_Freezeは出力されるファイルが1つではなく、作成された「.dllファイル」がないと正常に動作しません。<br>しかし、cx_Freezeでexe化したファイルは非常に起動が早いです。</p>



<p>インストールするには、コマンドプロンプトで次のように入力が必要です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>pip install cx_Freeze</code></pre></div>



<p>公式サイト：「<a target="_self" href="https://cx-freeze.readthedocs.io/en/latest/" title="cx_Freeze 6.15.0-dev3 documentation">cx_Freeze 6.15.0-dev3 documentation</a>」</p>



<h2 id="rtoc-13"  class="wp-block-heading">各種ライブラリの特徴</h2>



<p>例として取り上げた4つのライブラリは以下の通りです。自身に適したライブラリを使用してください。</p>



<p>個人的には、PyInstallerがもっと利便性が高いのでおすすめします。</p>



<figure class="wp-block-table aligncenter"><div class="scrollable-table"><table><tbody><tr><td class="has-text-align-center" data-align="center">ライブラリ</td><td class="has-text-align-center" data-align="center">特徴</td></tr><tr><td class="has-text-align-center" data-align="center">PyInstaller</td><td class="has-text-align-center" data-align="center">単一の実行可能ファイルに変換する。新しいPythonのバージョンに対応。</td></tr><tr><td class="has-text-align-center" data-align="center">py2exe</td><td class="has-text-align-center" data-align="center">単一の実行可能ファイルを作成。Windowsにのみ対応。</td></tr><tr><td class="has-text-align-center" data-align="center">Nuitka</td><td class="has-text-align-center" data-align="center">Pythonの実行速度をC言語に変換して解消。C言語でコンパイルするため作成に時間がかかる。</td></tr><tr><td class="has-text-align-center" data-align="center">cx_Freeze</td><td class="has-text-align-center" data-align="center">exe化したファイルの起動が非常に早い。実行には「.dllファイル」が必要。</td></tr></tbody></table></div></figure>



<h2 id="rtoc-14"  class="wp-block-heading">exe化の手順</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="533" src="https://alicia-ing.com/wp-content/uploads/2023/05/手順-1024x533.webp" alt="" class="wp-image-1944" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/手順-1024x533.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/05/手順-300x156.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/05/手順-768x400.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/手順-1536x800.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/05/手順.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>本記事では、<strong>「PyInstaller」</strong>を使用してexeファイルの作り方を紹介します。</p>



<p>PyInstallerのインストールには、Windowsに標準搭載されているコマンドプロンプトでインストールしていきます。</p>



<p>コマンドプロンプト・ターミナルはプログラミング初心者の方やウェブデザイン（html・CSS・JavaScript）をされる方にはあまり馴染みがないかと思います。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-question-circle"><span class="label-box-label-text block-box-label-text box-label-text">コマンドプロンプト/ターミナルとは</span></div><div class="label-box-content block-box-content box-content">
<p>・コマンドプロンプト</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Windows のコマンドプロンプトとは、普段マウスを用いて行っている操作を「コマンド」と呼ばれる命令文を入力して実行するものです。コマンドプロンプトでなければ操作できないこともあるため、知識として覚えておくことをおすすめします。</p>



<p>実際にWindows 上でコマンドプロンプトを起動すると、黒いバックグラウンドのサブウィンドウが表示され、コマンド入力の待機状態で上部に表示されます。<br>コマンドを入力し実行することでプログラムを起動することができ、また、実行したコマンドは一定数記憶されるため、再度実行する場合には簡単な操作で同じコマンドを実行することができます。</p>
<cite><a target="_self" href="https://jp.ext.hp.com/techdevice/windows10sc/27/" title="Windows 10 のコマンドプロンプトとは？その起動方法と使用例を紹介">Windows 10 のコマンドプロンプトとは？その起動方法と使用例を紹介</a></cite></blockquote>



<p>・ターミナル</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>「ターミナル」は、macOSにコマンドラインインターフェイスを提供します。「ターミナル」内の各ウインドウは、シェルプロセスのインスタンスを表します。ウインドウには、コマンドを入力できることを示すプロンプトが含まれます。表示されるプロンプトは「ターミナル」およびシェルの設定によって異なりますが、ほとんどの場合は、ログインしているホストの名前、現在の作業フォルダ、ユーザ名、およびプロンプト記号が含まれます。</p>
<cite><a target="_self" href="https://support.apple.com/ja-jp/guide/terminal/apd5265185d-f365-44cb-8b09-71a064a42125/mac" title="">Macで「ターミナル」を開く/終了する</a></cite></blockquote>
</div></div>



<p>特に、コマンドプロンプトやターミナルは、Pythonスクリプトのデバックだけではなく、<a target="_self" href="https://pillow.readthedocs.io/en/stable/" title="pillow">pillow</a>や<a target="_self" href="https://numpy.org/">Numpy</a>・<a target="_self" href="https://matplotlib.org/">Matplotlib</a>・<a target="_self" href="https://pandas.pydata.org/">pandas</a>・<a target="_self" href="https://scipy.org/">SciPy</a>など<strong>ライブラリをインストール</strong>する際にも使用します。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Numpy・Matplotlib・pandas・SciPyなど数値解析やデータサイエンスで使用するライブラリをまとめています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/statpy-library/" title="【Python】 統計処理・データ分析で必要なライブラリ一覧" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/statpy-library.webp" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">【Python】 統計処理・データ分析で必要なライブラリ一覧</div><div class="blogcard-snippet external-blogcard-snippet">統計学でよく使うライブラリ「Numpy・Matplotlib・Pandas・Scipy」の用途を確認するとともに、ソース...</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com/programming/python/statpy-library/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">alicia-ing.com</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>pillowは画像処理に使用します。QRコードの作成も可能です。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/qrcode/" title="【Python】pillowライセンス-URLからQRコード作成" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://alicia-ing.com/wp-content/uploads/2022/12/qrcode.webp" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">【Python】pillowライセンス-URLからQRコード作成</div><div class="blogcard-snippet external-blogcard-snippet">Python Pillowのライセンスはオープンソースで商用利用も可能なライブラリです。Pythonのqrcodeライブ...</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com/programming/python/qrcode/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">alicia-ing.com</div></div></div></div></a>
</div>



<h3 id="rtoc-15"  class="wp-block-heading">コマンドプロンプト起動・PyInstallerをインストール</h3>



<p>初めに、<strong>コマンドプロンプトを起動</strong>します。</p>



<p>コマンドプロンプトを呼び出すには、キーボードの<strong>Windowsマーク</strong>を押す。あるいは、ツールバーのwindowsのマークをクリックしてください。</p>



<p>そして、<strong>Windowsマーク内にある検索バー</strong>にて「コマンドプロンプト」と入力すると画像のようにコマンドプロンプトがアプリでヒットするので、起動してください。</p>



<figure class="wp-block-image aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="768" height="615" src="https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc.webp" alt="" class="wp-image-1800" style="width:576px;height:461px" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc-300x240.webp 300w" sizes="(max-width: 768px) 100vw, 768px" /></figure>



<p>画面が表示されましたら、前述したように、</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>pip install pyinstaller</code></pre></div>



<p>と入力します。</p>



<p>名称は「P」・「I」が大文字ですが、<br>入力文字は、<strong>全て小文字</strong>であることに注意してください。</p>



<p>画像のような表示になれば、インストール完了です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="768" height="404" src="https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc2.webp" alt="" class="wp-image-1802" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc2.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc2-300x158.webp 300w" sizes="(max-width: 768px) 100vw, 768px" /></figure>



<h3 id="rtoc-16"  class="wp-block-heading">Python　exe化</h3>



<p>次に、Pythonをexe化していきます。<br>今回は、スクリプト「Test.py」のexeファイル化を進めていきます。<br>ファイルの名前は<strong>簡単な英単語・数字</strong>にすることをおすすめします。</p>



<p>「22_01_11@ tEst.py」みたいに<strong>記号や小文字・大文字の混在、空白等</strong>を使用すると、<br>想定通りにexe化できないこともあるので、注意しましょう。</p>



<p>同じくコマンドプロンプトで、ソースコードを置いてあるところまで移動します。</p>



<p>コマンドプロンプトを開くと、「C:Users(名前)&gt;」となっています。<br>これは<strong>現在地</strong>を示していて、エクスプローラのファイルを開いていると考えてください。<br><br>例えば、画像のようにスクリプトをデスクトップ上に置いたのであれば、</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="768" height="402" src="https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc3.webp" alt="" class="wp-image-1803" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc3.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc3-300x157.webp 300w" sizes="(max-width: 768px) 100vw, 768px" /></figure>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>cd desktop</code></pre></div>



<p>と入力すると、<strong>現在地（作業フォルダー）がデスクトップ</strong>になります。<br>もし、<strong>作業フォルダーと保存フォルダーの場所が異なるとエラー</strong>が発生しますので注意してください。</p>



<p>次に、</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>pyinstaller Test.py</code></pre></div>



<p>と入力すると、Test.pyのexe化が開始されます。前回同様に「pyinstaller」は<strong>全て小文字</strong>です。</p>



<p>ファイルを1つにするときは、「<strong>&#8211;onefile</strong>」が必要です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>pyinstaller Test.py --onefile</code></pre></div>



<p>しばらく待つと、最後の行に、「<strong>completed successfully</strong>」と表示できれば、exe化完了です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="768" height="403" src="https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc4.webp" alt="" class="wp-image-1804" srcset="https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc4.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/05/command-Sc4-300x157.webp 300w" sizes="(max-width: 768px) 100vw, 768px" /></figure>



<p>完成したソフトは<strong>distファイル</strong>に保存されています。</p>



<h2 id="rtoc-17"  class="wp-block-heading">まとめ</h2>



<p>Pythonをexe化するには「PyInstaller」を使うことでことでコマンドプロンプトやターミナルなどのシェルでデバックが不要になります。</p>



<p>さらに、<strong>Python環境が構築をされていないPCでも起動可能</strong>で販売や配布ができて、とても便利です。<br></p>



<p>また、本記事でPythonスクリプトをexe化したときに使用したライブラリの<strong>PyInstallerは商用利用可能</strong>です。また、PyInstallerソースコードの変更も可能です。<br>ただし、<strong>変更を配布する場合は、GPL条項の下で配布</strong>しなければいけません。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/en/programming/python/exe-file/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
