How to load external Python modules?


After adding proper directory by appending sys.path variable still cannot load external modules.
Not DLL’s, but regular Python scripts. Even built-in modules like “sqlite3” and “xml” are not visible. Very annoying…


Hello Nikolay!

Try this:

import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\DLLs')
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')

import sqlite3
import xml

Loading Comtypes package in dynamo python
Python Nodes Basics

Works well, thanks. So we need to keep all modules in Python Interpreter folders? And add these lines of code to each python node?


I’m not sure if this answers your question, but you can place your python module anywhere you want as long as you append the path string to sys.path.


This is the problem - if I refer custom folders or Dynamo ones by sys.path it doesn’t help. I haven’t tried to refer both Lib and DLL folders - only this helps.
I think I will make a custom node with just correct initial code and place it every time I need a python node, some kind of a template. Thanks for help.