How to install Python modules in Dynamo Core Runtime 2.8.0?

By the way, are all these explained methods for Dynamo Sandbox or will they also work for Revit Dynamo?

The current version is compatible with 3.9

Yes

Have you changed the __init__.py file in the openseespywin folder?
Have you added the path to TCL?

If you are getting an error, upload a screenshot with the error expanded so it may be possible to diagnose any issues

1 Like

Thank you Mike for looking into this. Please see below:

What is the error when you try this code

import sys

from pathlib import Path
sys.path.append(str(Path.home().joinpath("AppData\\Local\\Apps\\Tcl86\\bin")))

import openseespywin

Strangely, I get this.

Solved with appending the address to the package location.
I don’t know why it was not looking at that location. :frowning:
Thank you for all the help, Mike!

1 Like

You can add the library path so that it is not hard coded as follows

import sys
import sysconfig
# ...
# site-package library paths
sys.path.append(sysconfig.get_path("platlib"))
2 Likes

So I have been using the openseespy successfully for a few cases. Now I am trying to see if I can use some visualization packages. I am looking at opsvis Welcome to Opsvis documentation! — opsvis 0.99.1 documentation
@Mike.Buttery just checking if you have tried this or anything similar to it. I successfully used it in a normal pyhton file but in Dynamo the plot does not show up. It does not give any errors though.

1 Like

The neatest trick I’ve seen to getting Matplotlib to show anything in Dynamo is to have it create a bitmap stream. This you can feed to the Dynamo Watch Image Node.
Python 3 Skelitonization - plt.show() not work - Developers - Dynamo

3 Likes

It looks like the path only needs to be added once, at least per user. I needed this code in Dynamo Sandbox 2.19 with Python 3.9.12 to get the shapely package to be found. Then ran Revit with the same Python version and ‘import shapely’ worked instantly.

1 Like

Thanks to the discussion here we were able to identify a bug in Dynamo around that missing site-packages path. Should be fixed in the next release! (or now in a daily build if you’re adventurous) It’s also fixed in the new PythonNet3 Python engine available on the package manager for Dynamo 3.3+.

2 Likes