# Embedding python for Tunny for Mac

**URL:** <https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647>\
**Category:** Rhino Developer\
**Tags:** windows, mac, python\
**Created:** [February 15, 2025, 10:33am UTC](https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647 "2025-02-15T10:33:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hiron](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hiron/32/702571_2.png) [@hiron](https://discourse.mcneel.com/u/hiron)\
**Post date:** [February 15, 2025, 10:33am UTC](https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647/1 "2025-02-15T10:33:43Z")

</div>

Hi forums and mcneel RhinoCode team,

Right now I am working on a mac version of Tunny, a multi-objective optimization tool.  
It has already reached the stage where it works as follows, but there is one problem.

Tunny is running Python behind the scenes and the windows version uses Embeddable Python. However, there is no mac version.  
So now it works in only my Python environment. This makes it difficult to distribute.

RhinoCode downloads Python3 and automatically embeds the Python file in /.rhinocode/py39-rh8.  
Does anyone know how this is done?

---

<div class="post-metadata">

**Author:** ![James\_Parrott](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/james_parrott/32/713265_2.png) [@James\_Parrott](https://discourse.mcneel.com/u/James_Parrott)\
**Post date:** [February 15, 2025, 3:39pm UTC](https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647/2 "2025-02-15T15:39:39Z")

</div>

By “Embeddable Python” are you compiling Python yourself in Visual Studio? Not using RhinoPython, or either Python component in Grasshopper?

The `.rhinocode` directory appears similar to the CPython embedded in Rhino 8. There’s probably been two years of work by the McNeel team to integrate Python 3.9. But I believe under the hood it uses PythonNet.

---

<div class="post-metadata">

**Author:** ![hiron](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hiron/32/702571_2.png) [@hiron](https://discourse.mcneel.com/u/hiron)\
**Post date:** [February 16, 2025, 2:49am UTC](https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647/3 "2025-02-16T02:49:10Z")

</div>

Thanks @James_Parrott

I also use Pythonnet in my implementation.  
Pythonnet only provides the Python manipulation part, not Python itself.

So I am looking into Python that can be distributed on mac.

---

<div class="post-metadata">

**Author:** ![James\_Parrott](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/james_parrott/32/713265_2.png) [@James\_Parrott](https://discourse.mcneel.com/u/James_Parrott)\
**Post date:** [February 16, 2025, 10:20am UTC](https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647/4 "2025-02-16T10:20:43Z")

</div>

Oh wow, that’s impressive, and advanced. Is there so much being sent from [Tunny](https://github.com/hrntsm/Tunny)’s C# to [Optuna](https://github.com/optuna/optuna), that it’s too much for native Grasshopper connections that the user should connect together to a Python component?

I’ve only called out to an external Python that the user has installed, but I haven’t tested the external application on MacOS.

---

<div class="post-metadata">

**Author:** ![rudolf.neumerkel](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rudolf.neumerkel/32/771158_2.png) [@rudolf.neumerkel](https://discourse.mcneel.com/u/rudolf.neumerkel)\
**Post date:** [February 17, 2025, 9:49am UTC](https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647/5 "2025-02-17T09:49:39Z")

</div>

> [@hiron](#):
>
> RhinoCode downloads Python3 and automatically embeds the Python file in /.rhinocode/py39-rh8.  
> Does anyone know how this is done?

Maybe @eirannejad can help here?

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/775509_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [February 18, 2025, 9:49pm UTC](https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647/6 "2025-02-18T21:49:11Z")

</div>

@hiron You’d need to manually build Python 3 from source on macOS and configure to be built as a framework.

I wonder if you can use the same python that is shipped with Rhino \>=8 in Tunny. How does Tunny use Python 3?

---

<div class="post-metadata">

**Author:** ![hiron](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/hiron/32/702571_2.png) [@hiron](https://discourse.mcneel.com/u/hiron)\
**Post date:** [February 18, 2025, 11:24pm UTC](https://discourse.mcneel.com/t/embedding-python-for-tunny-for-mac/199647/8 "2025-02-18T23:24:06Z")

</div>

Hi @eirannejad

> [@eirannejad](#):
>
> I wonder if you can use the same python that is shipped with Rhino \>=8 in Tunny. How does Tunny use Python 3?

Tunny has confirmed that it works with Python in Rhino \>= 8.

Python is connected to Grasshoper via Pythonnet, which is used to perform Galapagos-like optimizations using Python’s optimization library.

I was worried about conflicts with other packages in the existing RhinoCode, but your following article made me think that creating a site-envs folder for Tunny would not be a problem.

> **[Python Package Environments](https://developer.rhino3d.com/guides/scripting/advanced-pyvenvs/)**
>
> Provides information on managing multiple python package environments
