Python 3 libraries as extension dependencies

Hi pyRevit foaks, I am interested to understand what potential workflows can be used to ship python 3 libraries as dependecies for pyRevit extensions. In particular, I’d be interested in Numpy, SciPy and SpecklePy 2.0 (see docs here). Within our company, we have tried to wrap the libraries as pyRevit library extensions and add these as dependency to pyRevit extensions in the extension.json file, but this only works for a limited selection. See related issue in other thread here.

Has anyone been able to succesfully do this? Or can think of a method that can work?
I can think of two potential alternatives:

  1. From the extension startup.py: check if depencies are installed, if not, run a files download from desired PyPi project and unzip and run setup.py.
  2. Add all dependent modules and files to the extension repo in the lib folder. However, this bloats repo and not sure how scripts will be able to differentiate between python 2 and 3 modules.

Any thoughts are welcome :slight_smile:

1 Like

Hi @GooseG !

I took a look at the error you got in the other post (and maybe I should answer there!).
Looking at pyrevit code I saw that there is already an exception handling, so you may try to add StandardError to the exception to intercept. So that line becomes

except (AttributeError, StandardError):

Be aware that this is a workaround and many other issues can occur after that, but it is worth a try!

Just edit your C:\ProgramData\pyRevit\base\pyrevitlib\pyrevit\loader\sessionmgr.py file and see if it moves you forward.

I personally didn’t move to python 3 yet in pyrevit because of the many problems related to the pythonnet libary that is currently installed, but when we fixed that I’m sure I would like a way to import pandas in my scripts! :wink:

1 Like

Thanks @sanzoghenzo ! I will try this as soon as I have admin access and will report back with findings.