[python] How do I use modules from local CPython2.7 installation?

When using local IronPython installation one can use the modules from existing local CPython2.7 installation by creating a .pth file inside ipy2_install_folder\Lib\site-packages\

How can I do this with Rhino’s IronPython?

Hi @ivelin.peychev, in case the modules are compatible, have you tried to import them using the import statement ? (You might either import using the full path to the module (can be done with imp using imp.load_source) or set up the path from the editor:

Tools > Options > Files > Module Search Paths

_
c.

Thanks @clement,

I guess this is the main question.

I did not try imp.load_source but I tried two other options.

  1. the one I mentioned above. Adding .pth file, that failed. Apparently the embedded python engine does not behave the same as a standalone one.
  2. I tried to use pip as module to install from inside the code, but sadly sys.executable returns None :smiley:

You can also do sys.path.append(module_file_path) and try to import regular. But the module needs to be compatible.

_
c.

where are the modules installed?
\python-2.7.13.amd64\Lib\site-packages ?

Actually, never mind. I’ll figure it out. Incompatibility is also quite possible. I also already found a substitute to that module :slight_smile:

Thanks for all the help @clement.

C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib

1 Like

I see.