-
Notifications
You must be signed in to change notification settings - Fork 634
Access to Python 3 modules (Workaround)
While we are still working on an Officially Supported Way, here is how you can access these libraries today in Dynamo 2.7/2.8 as a workaround:
Note: Please make sure you are comfortable doing the following steps and make sure you read all of the Terms and Conditions.
Steps:
-
Download
Anaconda
- https://www.anaconda.com/products/individual -
After install, select the
CMD.exe Prompt
from the Home tab in the Anaconda Navigator (Install if you need to). -
This will open up the
Command prompt
in your (base) directory as Anaconda creates localized environments. -
Open up Dynamo 2.7 (or newer) and query the CPython version - as shown below (Note: Make sure you are in the CPython3 engine)
import sys
OUT = sys.version
- Go back to the Anaconda Command Prompt and create a new environment that uses the correct version of Python - In my case version 3.7.3. I’ve called this environment Dynamo373 and you use the following code to create it:
conda create --name Dynamo373 python=3.7.3
- You then want to activate this environment, and do so by typing the following code directly into your Anaconda Command Prompt:
conda activate Dynamo373
- You can then use Pip to install to this particular environment with:
pip install numpy
Note you can install other packages here, like Pandas or Keras etc.
-
Inside this Anacondas Command Prompt you will select the location path where they are being installed to your environment: In my case
c:\users\amours\anaconda3\envs\dynamo373\lib\site-packages
-
Back in Dynamo you will open up a new Python node, set it’s engine to CPython3 and then append this path to your sys.path location.
-
Then you can simply import all of your desired libraries!
# Load the Python Standard and DesignScript Libraries
import sys
import clr
sys.path.append(r'C:\Users\amours\anaconda3\envs\Dynamo373\Lib\site-packages')
import numpy
zeros = numpy.zeros(5)
output = zeros.tolist()
OUT = output
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