pyRevit icon indicating copy to clipboard operation
pyRevit copied to clipboard

allow pyRevit to use system Python and its packages

Open notionparallax opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

I can't work out how to install extra python packages.

There's an adsk forum post that explains how to use sys.path.append here. and I've tried that in a couple of different ways, and I get these sorts of error messages. ( The code that does this is here here )

['C:\\Users\\jstedman\\pymage\\CustomBVN.extension\\µ.tab\\BranchSwitch.panel\\update_branches.pushbutton', 'C:\\Users\\jstedman\\pymage\\CustomBVN.extension\\lib', 'C:\\Program Files\\pyRevit-Master\\pyrevitlib', 'C:\\Program Files\\pyRevit-Master\\site-packages']

Can't run this, you need to pip install this module

No module named 'hashlib'
some imports didn't work, you need to install them using pip. This is a bit of a dark art, and we need to work out good instructions on how to do this.

👆This one is adding to sys.path at the top, then importing git 👇This one is adding to sys.path inside the name==main part, then importing git

['C:\\Users\\jstedman\\pymage\\CustomBVN.extension\\µ.tab\\BranchSwitch.panel\\update_branches.pushbutton', 'C:\\Users\\jstedman\\pymage\\CustomBVN.extension\\lib', 'C:\\Program Files\\pyRevit-Master\\pyrevitlib', 'C:\\Program Files\\pyRevit-Master\\site-packages']

['C:\\Users\\jstedman\\pymage\\CustomBVN.extension\\µ.tab\\BranchSwitch.panel\\update_branches.pushbutton', 'C:\\Users\\jstedman\\pymage\\CustomBVN.extension\\lib', 'C:\\Program Files\\pyRevit-Master\\pyrevitlib']

CPython Traceback:
ModuleNotFoundError : No module named 'traceback'

pyRevitLabs.PythonNet
at Python.Runtime.Runtime.CheckExceptionOccurred()
at Python.Runtime.PythonEngine.ImportModule(String name)
at Python.Runtime.PythonException..ctor()
at Python.Runtime.Runtime.CheckExceptionOccurred()
at Python.Runtime.PyScope.Exec(String code, IntPtr _globals, IntPtr _locals)
at Python.Runtime.PyScope.Exec(String code, PyDict locals)
at PyRevitLabs.PyRevit.Runtime.CPythonEngine.Execute(ScriptRuntime& runtime)

As far as I can tell, the paths are clashing, and it can't work out how to look at both paths together.

The reason I can't update the windows PATH is that it's an admin locked thing, and that'd be too political to get into.

Describe the solution you'd like

  1. Ideally, I'm a chump, and it's easy, so point me at where this is documented.
  2. Write some documentation that explains how to do it
  3. Make it possible that each project can point to a lib folder, perhaps through a venv
  4. Make it possible for pyRevit to use the system python

Describe alternatives you've considered We've tried adding to the path, importing modules, and then removing the extra path location. And we've tried that in a few different places in the lifecycle of the script.

Additional context

The context for this is that I work with a bunch of people who do dirty things like have a four of 5 folders of pyRevit folders for dev, prod, and jens_special_pyrevit_hacks etc. This fills me with dread and I'd like to be able to have this managed through git branches. I thought I'd be good and add branch switching to the Revit UI, so if non-python users needed to use a different branch that had been made for them (e.g. panic_new_building_regs branch for just one project) they could.

I've made a POC that can make UI for switching branches and for pulling down the latest changes. But I can't work out how to add the GitPython module to the version of the engine that pyRevit uses.

We is @Jeenix and @notionparallax at @bvn-architecture

This seems somewhat related to:

  • #1628
  • #1524
  • #1512
  • #1438
  • #1351

notionparallax avatar Sep 30 '22 10:09 notionparallax