indigo-host and python import

Posted on
Wed Nov 18, 2020 1:05 pm
boisy offline
User avatar
Posts: 273
Joined: Jun 25, 2013

indigo-host and python import

I'm having some difficulty with indigo-host. Here's what I have:

1. A subfolder called "AlarmSystem" that contains two files: AlarmSystem.py and __init__.py
2. A file called "setAlarm.py" in the directory above that has this line: import AlarmSystem

If I invoke python interactively from the top level directory and type:

Code: Select all
import AlarmSystem


The module imports fine.

If I do this from indigo-host interactively, I get:

Code: Select all
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named AlarmSystem


Apparently something is different about how indigo-host sets up its environment that doesn't see the module in the current directory, but I'm at a loss to determine how to proceed. Any suggestions?

Posted on
Wed Nov 18, 2020 1:43 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: indigo-host and python import

It's a path issue. I'm not sure how you're running it from the first instance, but the indigo-host command is run in an IndigoPluginHost process. That process runs from the default path for any plugin, which is in this case the Server Plugin folder in a special plugin called InteractiveShell. Bottom line, it doesn't see your module. You can, however, add to the python search path so it can find it:

Code: Select all
import sys
sys.path.append("/full/path/to/module/parent/directory")


Basically, you're telling the python interpreter to look in all it's configured paths and in the directory that contains your module for valid modules.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 18, 2020 1:56 pm
boisy offline
User avatar
Posts: 273
Joined: Jun 25, 2013

Re: indigo-host and python import

Bingo, Jay! That did it! Thanks.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests