Why does Fusion have its own python version

Why does Fusion have its own python version

katharina_sinnabell
Explorer Explorer
720 Views
5 Replies
Message 1 of 6

Why does Fusion have its own python version

katharina_sinnabell
Explorer
Explorer

After a 3 year old workaround stopped working, I got pandas to work with the guide posted here: https://forums.autodesk.com/t5/fusion-api-and-scripts/import-data-from-excel-type-xlsx/m-p/11249210#... But after updating Fusion and then once again not being able to use pandas in my Add-in (this time apparently even pip has vanished), I am beginning to question, why Fusion needs its own python. Would it not be easier to let the user use their own installation and just adding the Fusion-only modules to it?

0 Likes
Accepted solutions (1)
721 Views
5 Replies
Replies (5)
Message 2 of 6

espablo
Enthusiast
Enthusiast

Create a Modules directory in your script directory and install the necessary libraries there and at the beginning of the code add

sys.path.append(os.path.join(os.path.dirname(__file__), "Modules"))

 

Message 3 of 6

katharina_sinnabell
Explorer
Explorer

I thank you for your answer, I previously tried the "installing into module folder next to script/add-in entry"-method as specified in the official documentation, but am not sure if I've tried connecting it like that yet. Will update 🙂

Still my question persists, why is it necessary for Fusion to have its own python?

0 Likes
Message 4 of 6

katharina_sinnabell
Explorer
Explorer

Im sorry, i was wrong in accepting the answer, it still does not work. My previous workaround was still active, that's why it seemed like it did for a second. At the moment it seems like the direct installation is the only way to make pandas available to my Add-in. The question of why all this is necessary unfortunately persists.

0 Likes
Message 5 of 6

BrianEkins
Mentor
Mentor
Accepted solution

The reason Fusion uses its own copy of Python is a result of how Fusion and the API are architected.  Fusion uses Python internally for a few things, and to get the best performance when running the API, Python needs to run within the Fusion process. As a result, Python is installed with Fusion, and this single instance is used for everything. All scripts and add-ins are sharing this single instance of Python. Theoretically, it could be possible to have an external Python that could talk to Fusion and drive the API, but it would require a marshaling layer that doesn't exist, and the performance would not be very good.

Because all scripts and add-ins share the same Python, Autodesk discourages installing into the system or editing sys.path. What if another add-in wants a different version of the same component you're trying to use? Unfortunately, there's not a good solution.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 6 of 6

katharina_sinnabell
Explorer
Explorer

Thank you for this answer! This explains a lot of the behavior I have been seeing in my pandas installation attempts.

0 Likes