Getting Started with Python4Delphi
Summary
TLDRこのビデオでは、Python for Delphiのセットアップ方法が説明されています。まず、SynEditをインストールし、次にPython4Delphiをバージョンコントロールから取得します。Pythonのインストールが完了すると、Pythonのビット数とアプリケーションのビット数が一致することを確認し、必要に応じて他のプラットフォーム用にPythonもインストールします。また、デモを通じてPythonを使用してGUIアプリケーションを構築する方法も紹介されています。
Takeaways
- 💻 まず、SynEditをインストールする。GetItから利用可能で、EULAに同意してダウンロード、パッケージの構築、IDEへのインストールを行います。
- 🔗 Python4DelphiはGetItからインストールするのではなく、Gitリポジトリからインストールします。RAD StudioのVersion ControlからGitソースを指定してインストールします。
- 🛠️ Python4Delphiをインストール後、パッケージをビルドしてIDEに追加します。
- 🐍 Python for Windowsをインストールする必要があります。Python 3を推奨していますが、Python 2は古く、サポートされていません。
- 📥 Pythonを再配布する場合は、埋め込み可能なZIPファイルをダウンロードできますが、フルインストーラーを使用することもできます。
- 💡 Pythonのビット数(32ビットまたは64ビット)は、構築するアプリケーションのビット数と一致する必要があります。
- 🔄 異なるプラットフォーム(macOSやLinux)にデプロイする場合は、それぞれのプラットフォーム用のPythonをインストールする必要があります。
- 🛠️ PIPはPythonのパッケージマネージャーであり、NumPyやTensorFlowなどのPythonパッケージをインストールするために使用できます。
- 📁 環境変数のPATHにPythonと関連ライブラリのパスを追加する必要があります。これにより、IDEが正しいPythonバージョンを認識できるようになります。
- 🔧 RAD Studioのデモプロジェクトを実行する際に、SynEditを使用してシンタックスハイライトやコードのインデント機能を利用できます。
Q & A
Python4Delphiとは何ですか?
-Python4DelphiはDelphiからPythonコードを実行するためのブリッジです。Delphiの環境内でPythonの機能を利用することが可能になります。
SynEditをインストールするために必要な手順は何ですか?
-まずGetItからSynEditをダウンロードし、EULAに同意してからパッケージをビルドします。その後、IDEにインストールされ、使用準備が整います。
Python4Delphiをインストールするためにはどの手順が必要ですか?
-Python4DelphiのリポジトリのURLをRAD Studioから開いて、バージョンコントロールからGitソースを選択し、フォルダを作成してからパッケージをインストールします。
Python for Windowsをインストールする際の注意点は何ですか?
-Python 3をインストールし、64ビットバージョンを推奨します。また、ビルドするアプリケーションのビットとPythonのビットが一致している必要があります。
Pythonを他のプラットフォーム(macOSやLinux)にインストールする場合のアドバイスは?
-各プラットフォーム用のPythonをインストールする必要がありますが、多くのLinuxディストリビューションではPythonが標準でインストールされている場合もあります。
PIPとは何ですか?
-PIPはPythonのパッケージマネージャーで、NumPyやTensorFlowなどのPythonパッケージをインストールするために使用されます。
パスの長さが長すぎるというエラーが出た場合、どのように対処しますか?
-パスの長さ制限を無効にすることで対処できます。これは環境変数の設定やシステムプロパティの調整を通じて行うことができます。
デモで使用されるPythonスクリプトを実行するにはどのようにすればよいですか?
-RAD Studioでデモプロジェクトを開いて、Pythonスクリプトを実行します。ただし、Pythonのライブラリパスが正しく設定されている必要があります。
SynEditが提供する機能は何ですか?
-SynEditはシンタックスハイライトやコードのインデント機能など、テキストエディタとしての機能を提供します。
Pythonの複数バージョンがインストールされている場合、どのように扱えばよいですか?
-システムにインストールされているPythonのバージョンを確認し、必要に応じてライブラリパスを調整してからビルドします。また、RAD StudioのPythonエンジン設定で特定のバージョンのDLLを指定することもできます。
Gitがインストールされていない場合、どのようにPython4Delphiのリポジトリを取得すればよいですか?
-Gitがインストールされていない場合は、ZIPファイルをダウンロードするか、GitHub Desktopを使用してリポジトリをクローンできます。
Outlines
💻 Python4DelphiとSynEditのインストールガイド
このセクションでは、Python4DelphiとSynEditのインストール方法について説明しています。まず、SynEditをインストールするためにGetItを使用し、EULAに同意してダウンロードとパッケージの構築を行います。次に、Python4Delphiをインストールするために、リポジトリのURLを取得し、RAD StudioからバージョンコントロールからGitを使用してインストールします。また、Python for Windowsのインストールも必要であり、Python 3のフルインストーラーを使用するか、またはWindowsストアからインストールすることができます。Pythonのビットバージョンは、構築するアプリケーションのビットバージョンと一致する必要があります。さらに、macOSやLinuxへのデプロイが必要な場合は、それぞれのプラットフォーム用のPythonをインストールする必要があります。
🐍 Pythonを使用したGUIアプリケーションの構築
このセクションでは、Pythonを使用してGUIアプリケーションを構築する方法について説明しています。デモプロジェクトを実行し、Pythonスクリプトの実行方法を紹介しています。また、SynEditを使用してシンタックスハイライトとコードのインデント機能を有効にする方法についても説明しています。さらに、システムに複数のPythonバージョンがインストールされている場合の対処方法や、特定のビットバージョンのPythonを使用する場合の設定方法についても触れています。最後に、Gitがインストールされていない場合の対処法や、GitHub Desktopを使用する方法についても紹介されています。
Mindmap
Keywords
💡Python4Delphi
💡SynEdit
💡EULA
💡Git
💡RAD Studio
💡Python 3
💡PIP
💡ビットネス
💡GetIt
💡エラーメッセージ
Highlights
Installing SynEdit from GetIt for Delphi IDE integration.
Accepting the EULA to download SynEdit packages for Windows.
Installing Python4Delphi by cloning the repository from Git.
Opening the Python4Delphi package after installation.
Building and installing the Python4Delphi package.
Installing Python for Windows to run Delphi applications.
Recommendation to use Python 3 over Python 2 for compatibility.
Installing the 64-bit version of Python for building Win64 applications.
The importance of matching Python's bittiness with the application's bittiness.
Installing Python for macOS or Linux if targeting those platforms.
Using PIP as the Python package manager to install additional packages.
Disabling the path length limit to avoid running out of path space.
Opening demo projects in RAD Studio to showcase Python for Delphi.
Error handling for missing files like 'definition.inc'.
Adding Python for Delphi libraries to the library path in RAD Studio.
Executing a Python script within a Delphi application.
Using SynEdit for syntax highlighting and behavior in Python scripts.
Building Win32 applications and the necessity of having both Python 32 and 64-bit versions.
Specifying Python engine settings in the Delphi designer.
The requirement of having Git installed for Python4Delphi installation.
Alternative methods for obtaining Python4Delphi without Git.
Transcripts
Last week during our Python for Delphi webinar, there was some questions about how to get
everything installed, set up.
So I'm going to walk you through installing a Python4Delphi, Python, and SynEdit.
So we'll start with SynEdit.
It's available in GetIt, and eventually Python4Delphi will be in there, but we're not installing
it from there today.
Accept the EULA it's now going to download SynEdit and then build all the packages for
windows.
So it's installed in the IDE and ready to go.
That's it we're done.
So now I'm going to install Python4Delphi.
To do that I have to come in here and get the URL for the repository right here.
And then go to RAD Studio, Open from Version Control, Git, source, destination, make a
folder to put it in.
And now it's going to ask you what project I want to a project or project group.
I want to install or want to open after installation.
And so I'm going to go ahead and open the package.
Right there, Python4Delphi.
Now I can build this, in theory.
Yup.
Builds it just fine and install it.
There's only one package right now.
And everything's been installed.
But in order to run anything, I need to install Python for Windows.
Now it recommends the.
Uh, Python 3.
Now there was some question redistributing Python.
So if you want to redistribute Python, um, you can just redistribute the, download the
embeddable right here in embeddable zip file.
And that would be the middle and that's like seven megabytes for that one.
I think it's eight, actually.
It's eight for that seven for that possibly.
Um, I'm going to go ahead and do the full installer though.
And you want Python 3, not Python 2.
Python 2 is very old at this point and he recommended you get Python 3.
So Python 3 finished installing or finished downloading so I'm going to run the installer.
And I think actually you can install it from the Windows store as wall, but I'm not positive.
And install now.
Yes.
And I am installing the 64-bit version.
The, um, I could install the 32-bit version as well, but I'm going to just build Win64
applications and use a 64 bit version.
So the bittiness of Python has to match the bittiness of the program you are building.
And if you want to deploy it for macOS or Linux, you would need to install the Python
for those platforms as well.
You could embed the embeddable version for all three platforms in there.
Although I think most, like I was going to say, I think most Linux distros have it by
default, but that's not true.
They don't it's, it's optional.
You can install it through, uh, the Linux package manager.
So PIP is the Python package manager that you can use to install Python packages.
If you wanted to install like num PI or TensorFlow or something like that.
Apparently my path is getting long.
So we'll go ahead and disable that limit.
So I don't run out of path space, always running out of path space.
OK, so now I'm in RAD Studio.
So I'm going to go ahead and open the Demos and demo 31 is the one that he showed off
during the webinar.
And, uh, yeah I'll go ahead and save change to that.
So this is SynEdit.
Actually, this is a memo.
Oh, this doesn't have SynEdit on here.
This is just using memos.
Actually, if we go back to here and go to demos.
See if one of these as using?
Nope.
None of these SynEdit haha so SynEdit gives you the syntax highlighting, but um, none
of these are using SynEdit.
Interestingly.
I thought they did while we were running this and uh, error.
Definition.Inc.
File not found definition.Inc.
So I want to explore.
I'm guessing it's in source ... definition.inc.
Yep.
Copy.
Uh, I need to go tools, options.
All of my Python for Delphi libraries, needs to be added to my path go the library path
and it's got SynEdit.
Added.
Automatically, but because I didn't install it from GetIt, which it's not, in GetIt yet.
So add, there we go.
And now, it should build.
Okay, so I'll run this execute.
Yeah, there we go.
So this is the, okay.
This is the one that shows how to use Python to, um, build a GUI application.
Can close, close dialogue.
Alright.
Yeah, that was the last one I showed.
So let's open up a different project demos, demo1, we'll start with one.
Okay.
Again, this is just a memo and a memo.
Yeah.
Execute script for.
So that's just a really simple one there.
Although let's go to replace this with a Senate.
Not that I can't rewrite that and we'll go SynEdit and we need to say.
It is spelled right: python, we need Python Behavior, and Python Syntax highlighting.
And then here we say, we want highlighter is Python and the behavior needs to point
to the editor SynEdit there.
So now we see we've got the blue on the numbers there and.
Um, we're just going to actually, let's just do this.
I'm going to cheat and just renamed this guy to memo1 and now cross our fingers.
Let's see if it works.
Okay.
Yep.
So not all works.
So I've just replaced that with SynEdit.
So SynEdit gives you the syntax highlighting also gives it the behavior.
So it knows how to do the indentation and stuff like that.
So if you had multiple versions of Python on your system, notice I'm building Win64.
If I was trying to do, Win32 let's go ahead and do that, now it should fail.
Let's see.
Oh, um, Library path add, there.
Save.
Now, it should build, but it shouldn't run.
Now it's failed because it can't find Python32.DLL.
So, and that gives me an error message and that's because I didn't install Python 32
I only installed Python 64.
So I've wanted to install both.
I would have to put both of them on there, or if I wanted to build Win32 ones.
But then also if we go into design, oops, I accidentally closed that if we go in here
into the designer, here is the Python engine, OK.
And the Python engine is where you can specify things.
So use last known version is what the default is.
If you wanted to, you could use, uh, a specific version of Python in here, a DLL name, so
right, here is where a specific version of the DLL and specific path, et cetera.
So there are go quick introduction to setting up and using Python for a Delphi.
Uh, if you don't have.
Git installed on your computer.
So you have to go install, Git options.
So you have to have Git installed.
And, uh, the path set up in here.
If you don't have that, then from here, you can just, um, download.
The zip file or use GitHub for Desktop to do it.
And for some reason, they've now got a GitHub command-line interface.
Instead of it used to have, they had to Git command line.
I don't know when they change that.
And now I get this weird, strange pink error box at the top.
So yeah, you can just download the zip file.
If you don't have Git installed on your computer.
There you go.
That's a quick introduction to setting up and using Python4Delphi.
浏览更多相关视频
how to disable applet mode + title override full memory mode
Simplest Way to Remove DRM from Books – No Kindle Serial Number Needed!
日本一わかりやすいStableDiffusion WebUI AUTOMATIC1111(ローカル版)のインストール方法と基本的な使い方
【完全攻略】Google Colaboratoryの使い方【Pythonの環境構築は不要】
Fabric: The Best AI Integration Tool For Obsidian
Python入門 第5回|基本のデータ型と型変換の関数を理解しよう【高校情報1】
5.0 / 5 (0 votes)