-
Notifications
You must be signed in to change notification settings - Fork 651
Customizing Dynamo's Python 3 installation
Dynamo uses what's called the Embeddable Package of Python. This allows Dynamo to have its own Python home, without requiring users to install Python or adding it to the PATH
. On the other hand this also makes it harder to find, and adds some extra considerations when installing packages. This guide will explain how to customize this installation.
Dynamo creates the Python home dynamically, so first of all you'll need to run any graph that contains a Python node using the CPython3
engine.
Open up a new Dynamo graph, place a single Python node
[1], double-click on the Python node to open up the Python editor
, change the engine dropdown to CPython3
[4] and run the graph [5]. There is no need to save it.
After this, the Python home will be created under your local application data folder. You can check this by opening up Windows Explorer
and typing into the navigation bar %localappdata%
, which will take you to your newly created Python home location [2]. Inside this folder, you will see a bunch of things and now, since we ran the Dynamo graph, you should also see a folder called python-<VERSION>-embed-amd64
[6].
What <VERSION>
you see will depend on the version of Python Dynamo is using:
- For Dynamo 2.7, this is Python version
3.7.3
- For Dynamo 2.8, this is Python version
3.8.3
- For all other versions of Dynamo, or if you are in doubt which is the correct version, you can always run this code in a Python node to ask Dynamo 😄 [3]
import sys
OUT = sys.version
If you are familiar with a regular Python installation, you'll notice the structure is different, but most of the components are there:
- DLL and PYD files are lying in the base folder rather than a subfolder. No big deal.
- Standard Lib is actually zipped in
python38.zip
. There is no need to extract it or add it to the path to use it, which is pretty amazing! - There is no
Scripts
folder andpip
is nowhere to be found [7]. This is a known caveat but it can be solved.
In order to make pip
available please follow these steps:
- Download get-pip.py [8] and place it into Dynamo's Python home [9][10].
- Edit the file named
python38._pth
[11] in Dynamo's Python home, removing the#
in the last line so that it readsimport site
[12].
- Navigate to your Python home [13] and copy the path. Inside the
Command prompt
application navigate to your Python version folder by typing into theCommand prompt
the path of where your Python version lives. It should look something like this:cd C:\Users\<USERNAME>\AppData\Local\python-<VERSION>-embed-amd64
[14] wherecd
is a call tochange directory to
your path.
- Now that you are in the correct folder, you can run
python get-pip.py
[15], which will download and install pip - a successful install will be returned [16], as will any warnings.
After doing that you should see the Scripts
folder, containing pip
.
Now that you have pip
, this part is no different than in any regular Python installation. All you need to do is run .\Scripts\pip install <ANY_PACKAGE>
and it will get downloaded under the Lib
folder.
You might be surprised but no. Installed libraries are already available, you don't need to add anything to sys.path
or do anything special.
Good question! Virtual environments are not supported by the Python Embeddable Package, probably because, in a way, this is a special Python installation specific for a single application.
Looking for help with using the Dynamo application? Try dynamobim.org.
- Dynamo 2.0 Language Changes Explained
- How Replication and Replication Guide work: Part 1
- How Replication and Replication Guide work: Part 2
- How Replication and Replication Guide work: Part 3