How to install Python modules in Dynamo Core Runtime 2.8.0 ?
Just need to import them as you would all the way back in Dynamo 2.0 (and likely before that too).
import clr, which imports the common language runtime into Dynamo’s Python integration. This presentation has a good breakdown: https://github.com/Amoursol/dynamoPython/blob/master/images/DivingDeeper_ABeginnersLookAtPythonInDynamo_AU_London2018.pdf
Another slightly more complex example from this thread:
import sys sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib') import ctypes
which adds the ctypes library to the associated Python node.
No IronPython) Dynamo Core Runtime 2.8.0 have a normaly Python 3.8
Hello @Khasan_Mamaev - the Daily Builds as of today have access to different
Python Engines as follows, but still use
IronPython2 as the default - which has historically been in Dynamo
We have a
task to explore how we want to support this and will be writing a
blog post afterwards, but as of right now we do not have an officially supported way
Downloading locally in advance and importing the package via the by directory should work for the time being, right?
Hello @Khasan_Mamaev, 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
- After install, select the
CMD.exe Promptfrom the Home tab in the Anaconda Navigator (Install if you need to).
- This will open up the Command prompt
inyour (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
5. Go back to the Anaconda Command Prompt and create a
new environmentthat uses the correct version of Python - In my case version 3.7.3. I’ve called this environment
Dynamo373and 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
Pipto install to this particular environment with:
pip install numpy
Note you can install other packages here, like Pandas or Keras etc.
8. Inside this Anacondas Command Prompt you will select the location path where they are being installed to your environment: In my case
9. Back in Dynamo you will open up a new Python node, set it’s
engineto CPython3 and then append this path to your
10. 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
This is great, but why it only works when using “pip install”, and warning errors using “conda install” ?
I’m unsure sorry @Jimmy1 - would have look into Anaconda itself
Works perfect!!! Thanks!!!
Good job! Thanks ! I have done it as you showed . If there is someone who don’t need the whole Anaconda , he can install only numpy . of course , he must add the path of the numpy into sys.path instead of the path of Anaconda .
Indeed there is - this was a workaround until we published a new method, of which we did a day or so ago - you can access it here: https://github.com/DynamoDS/Dynamo/wiki/Customizing-Dynamo’s-Python-3-installation