I try to use python once on Unity and I found a few ways:

  1. There is a package call "IronPython" where you can add a python file to your unity project and then call a function from C# to your python code, to do that you should follow this:

We already know that we can use python to use .net internal calls. Now we may use the same to start a console that can accept a scripting language in Unity engine. To do this we have to include certain dll files. These dll files must be present in Assets>plugins

IronPython.dll
IronPython.Modules.dll
Microsoft.Scripting.Core.dll
Microsoft.Scripting.dll
Microsoft.Scripting.Debugging.dll
Microsoft.Scripting.ExtensionAttribute.dll
Microsoft.Dynamic.dll

Once the Plugins are in place.

Initiate the Cs code

PythonEngine engine = new PythonEngine(); 
engine.LoadAssembly(Assembly.GetAssembly(typeof(GameObject))); 
engine.ExecuteFile("Test.py");

Where test.py is the python code.

Initiate python side:

import UnityEngine from UnityEngine 
import * 
Debug.Log("Hello world from IronPython!")

References: https://github.com/cesardeazevedo/Unity3D-Python-Editor http://techartsurvival.blogspot.in/2013/12/embedding-ironpython-in-unity-tech-art.html IronPython in Unity3D

the issue with this way is that most of the python module are not supported.

2.the second way is to create a file like json that contain the data you want to send to the json and then create an output json that send the output from the python script, this way is very limited with what you can send because the data must be contain in your json.

  1. the last way that work for me is to install the Nuget package and copy the script from python to c# line by line with the relevent module installed in Unity and it's work for me, but copy a long code can take time. this is a reference to the package: https://github.com/GlitchEnzo/NuGetForUnity and then to install the relevent package you should press on NuGet → Manage NuGet Packages and the choose the relevent package(for me it was Numpy and it work grate).

hope it will help you

Answer from Noam Riahi on Stack Overflow
🌐
Unity
docs.unity3d.com › Packages › com.unity.scripting.python@2.0 › manual › index.html
Python for Unity | 2.0.1-preview.2
Automating time consuming tasks like duplicating or modifying a large quantity of Assets. Authoring custom editor tools that could both use complex UI elements and interact natively with other DCC suites. Python for Unity requires installing third-party software.
Discussions

How do to use a python script in Unity? - Stack Overflow
I'm trying to run a face detection model in Unity. It gets input from the webcam, then spits out a face. But trying to make this work with C# has been an absolute nightmare. And despite all my suff... More on stackoverflow.com
🌐 stackoverflow.com
Why is the Python Scripting Package support ending?
Will there be an alternative solution to use Python in the editor? I found that the Python Scripting Package is very useful when building tools for the Unity Editor to create assets. For example using open source AI models like coqui text-to-speech. Accessing the vast Python package catalogue ... More on discussions.unity.com
🌐 discussions.unity.com
4
5
November 1, 2024
Python for Unity Editor Only - Unity Engine - Unity Discussions
Hi, I’m wondering if Python for Unity will always only be editor-only, or if there are plans to make it work with standalone builds? I’m trying to run external Python scripts in the best way and then read back their results, not really to control Unity with Python specifically. More on discussions.unity.com
🌐 discussions.unity.com
0
June 18, 2020
Coding in unity with python?
I know the main language for unity is C# but its to crazy for my little brain. I knew python was a bit easier but wasn’t sure if unity supports it or has a asset to support it. I saw there’s a way to support it or something similar but wasn’t sure of the limitations on it? More on discussions.unity.com
🌐 discussions.unity.com
6
0
March 8, 2022
🌐
Unity
discussions.unity.com › unity engine
Running Python in Unity - Unity Engine - Unity Discussions
April 8, 2025 - Hello, I’m working on a game project where players need to place rescue stations optimally on a map, balancing coverage, cost, and positioning. The optimization algorithm to solve this problem has already been provided in Python, and it works well. Now, I need to implement this logic into my Unity game.
Top answer
1 of 5
2

I try to use python once on Unity and I found a few ways:

  1. There is a package call "IronPython" where you can add a python file to your unity project and then call a function from C# to your python code, to do that you should follow this:

We already know that we can use python to use .net internal calls. Now we may use the same to start a console that can accept a scripting language in Unity engine. To do this we have to include certain dll files. These dll files must be present in Assets>plugins

IronPython.dll
IronPython.Modules.dll
Microsoft.Scripting.Core.dll
Microsoft.Scripting.dll
Microsoft.Scripting.Debugging.dll
Microsoft.Scripting.ExtensionAttribute.dll
Microsoft.Dynamic.dll

Once the Plugins are in place.

Initiate the Cs code

PythonEngine engine = new PythonEngine(); 
engine.LoadAssembly(Assembly.GetAssembly(typeof(GameObject))); 
engine.ExecuteFile("Test.py");

Where test.py is the python code.

Initiate python side:

import UnityEngine from UnityEngine 
import * 
Debug.Log("Hello world from IronPython!")

References: https://github.com/cesardeazevedo/Unity3D-Python-Editor http://techartsurvival.blogspot.in/2013/12/embedding-ironpython-in-unity-tech-art.html IronPython in Unity3D

the issue with this way is that most of the python module are not supported.

2.the second way is to create a file like json that contain the data you want to send to the json and then create an output json that send the output from the python script, this way is very limited with what you can send because the data must be contain in your json.

  1. the last way that work for me is to install the Nuget package and copy the script from python to c# line by line with the relevent module installed in Unity and it's work for me, but copy a long code can take time. this is a reference to the package: https://github.com/GlitchEnzo/NuGetForUnity and then to install the relevent package you should press on NuGet → Manage NuGet Packages and the choose the relevent package(for me it was Numpy and it work grate).

hope it will help you

2 of 5
2

We are thrilled to announce that Python for Unity 4.0.0-exp.5 is now available!

4.0.0-exp.5 is a major upgrade from our last public release, and incorporates a large number of changes. In summary: Based on Python 3.7; scripts based on Python 2.7 will need to be ported. Users no longer need to install Python on their system. In-process Python is no longer reinitialized when the Unity domain reloads. Removed the out-of-process API. The PySide example now runs in-process and is much simpler. Limited support for a virtual environment workflow via the ProjectSettings/requirements.txt file. Many bug fixes. Documentation for the Python for Unity package is available here, and the full changelog can be found here.

This is an experimental release, and thus is not visible in Package Manager. To install this package, open Package Manager, click the + at the top left and select Add package by name.... Enter com.unity.scripting.python as the name and and 4.0.0-exp.5 as the version and click Add. Alternatively, you may edit Packages/manifest.json and add "com.unity.scripting.python": "4.0.0-exp.5", to the list of dependencies, or edit the existing entry for Python for Unity to update the version.

Soursce: https://forum.unity.com/threads/python-for-unity-release-announcements.1084688/

Documentation: https://docs.unity3d.com/Packages/[email protected]/manual/index.html

🌐
GitHub
github.com › exodrifter › unity-python
GitHub - exodrifter/unity-python: Python plugin for Unity3D. · GitHub
UnityPython is a plugin for Unity3D that provides support for running Python 2.x code in Unity3D on any platform which supports System.Reflection.Emit.
Starred by 354 users
Forked by 90 users
Languages   Python
🌐
Unity
discussions.unity.com › unity engine
Why is the Python Scripting Package support ending? - Unity Engine - Unity Discussions
November 1, 2024 - The Python Scripting Package documentation says the support is scheduled to end with Unity 6.1. What is the reason for this? Will there be an alternative solution to use Python in the editor? I found that the Python Scripting Package is very useful when building tools for the Unity Editor to create assets.
Find elsewhere
🌐
Unity
docs.unity3d.com › Packages › com.unity.scripting.python@6.0 › manual › index.html
Python Scripting | Python Scripting | 6.0.1
Automating scene and sequence assembly in the context of using Unity as a real-time renderer. Automating time consuming tasks like duplicating or modifying a large quantity of Assets. Authoring custom editor tools that could both use complex UI elements and interact natively with other DCC suites. ... A Python Script Editor window principally aimed at Technical Artists who want to run short scripts and easily create new menu items that run Python code.
🌐
GitHub
github.com › K0lb3 › UnityPy
GitHub - K0lb3/UnityPy: UnityPy is python module that makes it possible to extract/unpack and edit Unity assets · GitHub
UnityPy is python module that makes it possible to extract/unpack and edit Unity assets - K0lb3/UnityPy
Author   K0lb3
🌐
Unity
discussions.unity.com › unity engine
Python for Unity Editor Only - Unity Engine - Unity Discussions
June 18, 2020 - Hi, I’m wondering if Python for Unity will always only be editor-only, or if there are plans to make it work with standalone builds? I’m trying to run external Python scripts in the best way and then read back their res…
🌐
Unity
docs.unity.com › en-us › cloud › asset-manager › python-sdk
Unity Cloud Python SDK • Unity Cloud • Unity Docs
The Unity Cloud Python SDK helps connect your Python app to Unity Cloud services. It supports authorization and asset management, making it ideal for developers building custom Asset Manager integrations or automating asset workflows.
🌐
Unity
discussions.unity.com › unity engine
Coding in unity with python? - Unity Engine - Unity Discussions
March 8, 2022 - Hello there! So I’ve bean doing bolt on unity for a while now (visual scripting) and kinda wanted to try real scripting. I know the main language for unity is C# but its to crazy for my little brain. I knew python was a…
🌐
Unity
unity.com
Unity: Develop, Deploy, and Grow | The World's Leading Game Engine
Whether it’s your first prototype or your next hit, you can develop, deploy, and grow your game with Unity. The same tools that power hit mobile, PC, console, XR, and web games are ready and waiting for you.
🌐
Unity
discussions.unity.com › news & general discussion
We need a Python Integration into Unity for AI ! Or some C# library integration - News & General Discussion - Unity Discussions
September 4, 2024 - Hello all, MLagents is amazing and the number 1. reason why haven’t switched to other Game Engines yet (besides easy compute shaders, HDRP, C# etc.). But tbh I would like to be more flexible, using own DeepLearning implementations etc. We really need either a better documentation for the ML gym or some new system to simply use ML in Unity.
🌐
Medium
medium.com › @hanlanyi › an-ultimate-guide-of-using-python-in-unity-part-i-5d665360c4b8
An Ultimate Guide of Using Python in Unity (Part I) | by HAN, Lanyi | Medium
June 8, 2024 - Although python scripts are mostly short and easy to debug, Jupyter Notebook boosts the process even more efficient. ... Jupyter Lab is recommended, or every single click opens a new tap sounds reasonable, then jupyter notebook can also be tested, although people will always choose back to Jupyter Lab. Once it is installed, a simple “jupyter lab” on Unity python script terminal will open a web page instantly, which is the exact location of the Unity Project.
🌐
Unity
docs.unity3d.com › Packages › com.unity.scripting.python@6.0 › manual › inProcessAPI.html
Using the Python API | Python Scripting | 6.0.1
For example, this Python script loops over all the GameObjects in a scene and makes sure all the names end up with an underscore: import UnityEngine all_objects = UnityEngine.Object.FindObjectsOfType(UnityEngine.GameObject) for go in all_objects: if go.name[-1] != '_': go.name = go.name + '_'
🌐
Unity
discussions.unity.com › unity engine
Python for Unity Install - Unity Engine - Unity Discussions
May 19, 2021 - Hi, I’m new to unity and trying to install the Python for Unity package (specifically version 4.0.0-exp.5) however I’m unable to locate it in Package Manager and I have found no way to download the package from the web. …
🌐
Medium
codemaker2016.medium.com › how-to-run-your-python-code-in-unity-bb652d374bd3
How to run your Python code in unity | by Vishnu Sivan | Medium
April 12, 2022 - Here we are going to explore python integration in two ways. UnityPython is a plugin for Unity3D that provides support for running Python 2.x code in Unity3D on any platform which supports System.Reflection.Emit
🌐
Unity
docs.unity3d.com › Packages › com.unity.scripting.python@7.0 › manual › install-python-modules.html
Install Python modules and packages | Python Scripting | 7.0.2
Use pip to install the desired Python package. For example: python -m pip install PySide2. Unity installs the Python package in the following folder of your Unity project: Library/PythonInstall/Lib/site-packages.
🌐
Reddit
reddit.com › r/gamedevelopment › learning with python or comfort with unity?
r/GameDevelopment on Reddit: Learning with python or comfort with unity?
June 18, 2023 -

Hello everyone. I would like to learn how to develop video games for fun, learning and possibly for a gift. In particular, I'm interested in developing 2D video games. But I have a problem: python is the only language I know and I use it for work and one of my side goals would be to take advantage of game development to be able to practice in python and learn new things. However, I am afraid that development in python is more complicated and even if I have seen that there are engines that support python, they seem less efficient and comfortable than other engines such as unity, or in any case they are less used and therefore there are fewer resources to learn. So I fear that developing in python could lead to worse results with more effort and more time, ruining the experience overall. What do you recommend?

Top answer
1 of 3
5
I highly recommend Godot. That's what I used to learn Game Dev and the native GDscript is almost indistinguishable from python. It's quite versatile, but best used for 2D. It also has quite a lot of tutorials/community to ask questions. If you want to, ask me.
2 of 3
2
(I am ChatGPT-powered bot that tries to answer questions in r/GameDevelopment . Feel free to downvote this comment if you don't find it relevant). I recommend trying both Python-based and Unity game development to see which one suits your needs and preferences better. Here are some options for each: Python-based game development: Pygame: A popular library for creating 2D games in Python. It has a large community and many resources available. Godot: A powerful game engine with built-in support for Python-like scripting language called GDScript. It's beginner-friendly and has a growing community. Panda3D: A 3D game engine with Python support, suitable for creating both 2D and 3D games. It has a smaller community but is still actively maintained. Unity game development: Unity 2D: Unity is a widely-used game engine with a large community and extensive resources. It primarily uses C# for scripting, but learning C# will be beneficial in the long run. Playmaker (Unity plugin): A visual scripting tool for Unity that allows you to create game logic without writing code. It can be a good starting point if you're not comfortable with C# yet. Consider your goals, available resources, and personal preferences when making a decision. If you want to focus on Python, try Pygame or Godot. If you're open to learning a new language and want a more established engine, Unity might be a better choice. (This bot may produce inaccurate information--verify when it matters!)