Import pandas not working in Revit 2023.1.2 and Dynamo 2.16

Hi all,

I’ve followed this guide to install pandas

I get the error

image

import pandas as pd

It’s not just pandas but also any package.It was working before upgrading to Revit 2023.1.2 and Dynamo 2.16

packages are installed. See below

image

1 Like

Update

I’ve added the path but isn’t supposed to work without it according to the guide above?

import sys
sys.path.append(r'C:\Users\<User>\AppData\Local\python-3.9.12-embed-amd64\Lib\site-packages')

Hi,
you can use the Python.Included library

import clr
import sys
import System

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

clr.AddReference('Python.Included')
import Python.Included as pyInc
path_py3_lib = pyInc.Installer.EmbeddedPythonHome
sys.path.append(path_py3_lib + r'\Lib\site-packages')

import pandas as pd
import numpy as np

lstPts = [DS.Point.ByCoordinates(*np.random.randint(10, size=3))  for i in range(100)]

# Create the pandas DataFrame with column name is provided explicitly
df = pd.DataFrame({'Point' : lstPts})
df["Z"] = df.apply(lambda row : row['Point'].Z, axis=1)

OUT = repr(df)
3 Likes

@c.poupin thanks for the workaround but my question is why is not working automatically has per the guide above ? why are Revit upgrades affecting the way is working ?
is anyone in DynamoTeam able to reproduce and confirm why this is happening ?

Can you confirm the Python engine in Dynamo for Revit? May be that PIP is set up to push to the wrong directory.

see here (bottom of page)

1 Like