|
|
|
|
Reply From: |
sustainablelab |
For other people that found there way here looking to use Python in Godot, the GitHub - touilleMan/godot-python: Python support for Godot 🐍🐍🐍 project (PythonScript in the AssetLib) is active and completely usable, though it is still in beta.
I just installed it today and was able to use Python packages for USB serial communication in my Godot project. From the older posts here, it sounds like this used to be much harder than it is now. My experience with PythonScript so far is extremely positive.
Here is a quick start aimed at people familiar with Python but still new to Godot (e.g., me):
- *ex: create a project named "Talk-to-Python"*
- click
AssetLib
- search for
PythonScript
- download (will take a while and appears to hang, just be patient)
- click
Install
- optionally, uncheck the folders for operating systems that
are not the operating system you're installing this on
- create a node
- *ex: `Node2D` named `Main`*
- save the scene
- *ex: `Main.tscn`*
- quit to Project Page
- `Ctrl+Shift+Q`
- re-open this project
Attach a script to the Main
node. In the dialog, Python is now a language option! Pick Python and let it generate the default script.
Install packages with pip from the command line as usual. Just a little setup:
cd
into the folder for your OS, e.g. on Windows 64bit cd
into the windows-64
folder
python.exe
runs the Windows installation of Python, but I want the python.exe
in this folder, so prefix with ./
:
mike@HOME ~/godot-games/talk-to-python/addons/pythonscript/windows-64
$ ./python.exe -V
Python 3.8.5
The Python installed by PythonScript only has one package, godot
. So first install pip
as follows:
$ ./python.exe -m ensurepip
Looking in links: c:\cygwin64\tmp\tmprt3m6lj0
Requirement already satisfied: setuptools in c:\users\mike\appdata\roaming\python\py
thon38\site-packages (47.3.1)
Processing c:\cygwin64\tmp\tmprt3m6lj0\pip-20.1.1-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-20.1.1
And update pip:
$ ./python.exe -m pip install -U pip
Now install whatever is needed:
$ ./python.exe -m pip install pyserial
Sorry, figured it out. Don’t know how to delete comment
BallWave | 2021-02-20 23:38
On Ubuntu, i’m getting this error:
ModuleNotFoundError: No module named 'pip._internal'; 'pip' is not a package
Any thoughts?
MomoVR | 2022-07-21 20:23