How to install python modules in Indigo 7

Posted on
Tue Nov 15, 2016 12:36 pm
lindehoff offline
Posts: 80
Joined: Aug 08, 2015

How to install python modules in Indigo 7

Hi
For some reason python modules I install are not found within plugins after I upgraded to Indigo 7.
I know that Indigo 7 uses python 2.7 and I have reinstall the modules for 2.7.

I have tried multiple different ways and different modules, all with and without sudo:
Code: Select all
pip install numpy

Code: Select all
pip2.7 install numpy

Code: Select all
sudo easy_install-2.7 pip numpy


I don't get any errors installing the modules and the are accessible within python:
Code: Select all
python
Python 2.7.10 (default, Sep 23 2015, 04:34:14)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>


Even if I run the Scripting Shell it works:
Code: Select all
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
Connected to Indigo Server v7.0.1, api v2.0 (localhost:1176)
>>> import numpy
>>>


But when I try to start a plugin that uses that module I get:
Code: Select all
   Hue Lights Error                Error in plugin execution InitializeMain:

Traceback (most recent call last):
  File "plugin.py", line 427, in <module>
  File "/Library/Application Support/Perceptive Automation/Indigo 7/Plugins/Hue Lights-2.indigoPlugin/Contents/Server Plugin/colormath/color_objects.py", line 4, in <module>
ImportError: No module named numpy

   Stopping plugin "Hue Lights 1.4.4" (pid 461)

Posted on
Tue Nov 15, 2016 8:15 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: How to install python modules in Indigo 7

During the beta of Indigo one of the plugin developers noticed on his Mac, somehow, he ended up with 2 different versions of Python 2.7: 2.7.10 and 2.7.12.

He would get 2.7.10 if he started python with just python:

$ python --version
Python 2.7.10

But would get 2.7.12 if started with python2.7:

$ python2.7 --version
Python 2.7.12

I wonder if that is what is happening here?

I am puzzled by the different results you see when trying to import the module from Indigo's plugin shell versus from the plugin. Under-the-hood those are started up exactly the same way.

Image

Posted on
Tue Nov 15, 2016 11:31 pm
srkinard offline
Posts: 320
Joined: Apr 10, 2016
Location: Austin, Texas

Re: How to install python modules in Indigo 7

Maybe something in how the plugin calls other python scripts?

When I used SickRage they made some changes in certain modules that called python2 vs just python and my system didn't understand the python2 command.

The devs rolled back to previous behavior and changed the way it was called, but only after a lot of complaints...since it was cross-platform code that worked on the Mac with native 2.6 or 2.7 and failed on some Linux distros and Windows installs.

I have no idea if that's anything close to what's happening here, but based on Matt's post about the multiple versions, anything is possible.

Posted on
Wed Nov 16, 2016 1:31 am
lindehoff offline
Posts: 80
Joined: Aug 08, 2015

Re: How to install python modules in Indigo 7

matt (support) wrote:
During the beta of Indigo one of the plugin developers noticed on his Mac, somehow, he ended up with 2 different versions of Python 2.7: 2.7.10 and 2.7.12.

He would get 2.7.10 if he started python with just python:

$ python --version
Python 2.7.10

But would get 2.7.12 if started with python2.7:

$ python2.7 --version
Python 2.7.12

I wonder if that is what is happening here?

I am puzzled by the different results you see when trying to import the module from Indigo's plugin shell versus from the plugin. Under-the-hood those are started up exactly the same way.


I saw that post but I don't have that problem:
Code: Select all
$  python --version
Python 2.7.10
$  python2.7 --version
Python 2.7.10


I also tied to import in a simple script but it did not work:
Image
Image

Posted on
Wed Nov 16, 2016 11:11 am
jay (support) offline
Site Admin
User avatar
Posts: 18216
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How to install python modules in Indigo 7

Look to see if numpy is in this directory:

Code: Select all
/Library/Python/2.7/site-packages/

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 16, 2016 11:24 am
lindehoff offline
Posts: 80
Joined: Aug 08, 2015

Re: How to install python modules in Indigo 7

jay (support) wrote:
Look to see if numpy is in this directory:

Code: Select all
/Library/Python/2.7/site-packages/


No modules in the folder only a README file:
Code: Select all
This directory exists so that 3rd party packages can be installed
here.  Read the source for site.py for more details.

Posted on
Wed Nov 16, 2016 12:05 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: How to install python modules in Indigo 7

I'm the one with the mystical python 2.7.12 that I believe either came along for the ride with a reinstall of XTOOLS or, upon further reflection, could have hitched a ride with Macports. I never asked to install 2.7.12 (I'm on El Capitan).

On my development environment, I did the following:
Code: Select all
username$ python --version
Python 2.7.10
to ensure that my default Python was 2.7.10.


Code: Select all
sudo pip install ipgetter


Launched a Python shell from within Indigo
Code: Select all
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]
Connected to Indigo Server v7.0.1, api v2.0 (localhost:1176)
>>> import ipgetter
>>>


For the record, here's what happens if I do this:
Code: Select all
username$ python2.7 --version
Python 2.7.12

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Nov 16, 2016 1:02 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: How to install python modules in Indigo 7

lindehoff wrote:
jay (support) wrote:
Look to see if numpy is in this directory:

Code: Select all
/Library/Python/2.7/site-packages/


No modules in the folder only a README file:
Code: Select all
This directory exists so that 3rd party packages can be installed
here.  Read the source for site.py for more details.

Can you find where it got installed?

Image

Posted on
Wed Nov 16, 2016 1:32 pm
lindehoff offline
Posts: 80
Joined: Aug 08, 2015

Re: How to install python modules in Indigo 7

matt (support) wrote:
Can you find where it got installed?


My module seems to be installed here
Code: Select all
/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages


I found that you can run
Code: Select all
import site; site.getsitepackages()
to list the module dirs,
Here is my result in different environments
Terminal running python
Code: Select all
$ python
Python 2.7.10 (default, Sep 23 2015, 04:34:14)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import site; site.getsitepackages()
['/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/site-python', '/Library/Python/2.7/site-packages']


Inside a script executed from Indigo
Code: Select all
import site
indigo.server.log(str(site.getsitepackages()))
Result in Log:
16 Nov 2016, 20:28:22
Script                          ['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/Library/Python/2.7/site-packages']


Indigos Scripting Shell
Code: Select all
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
Connected to Indigo Server v7.0.1, api v2.0 (localhost:1176)
>>> import site; site.getsitepackages()
['/usr/local/bin/../Cellar/python/2.7.10_2/bin/../Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/usr/local/bin/../Cellar/python/2.7.10_2/bin/../Frameworks/Python.framework/Versions/2.7/lib/site-python', '/Library/Python/2.7/site-packages']
>>>


Posted on
Wed Nov 16, 2016 1:53 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: How to install python modules in Indigo 7

That is because when launched from an interactive shell (terminal or Indigo's shell) it includes your .bash (or other) files that setup different folder paths.

I'd suggest you make a symbolic link from where it was installed into your /Library/Python/2.7/site-packages/ folder so Indigo can find it.

Image

Posted on
Wed Nov 16, 2016 1:55 pm
lindehoff offline
Posts: 80
Joined: Aug 08, 2015

Re: How to install python modules in Indigo 7

Yes I tried that and it worked perfectly. Thanks for all the help.

Posted on
Wed Nov 16, 2016 3:03 pm
jay (support) offline
Site Admin
User avatar
Posts: 18216
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How to install python modules in Indigo 7

Did you/do you have Mac OS X server installed by any chance?

[EDIT] it looks like you (or perhaps something else) caused homebrew to install Python (the /Cellar/ in the path above gave it away). While we understand wanting to keep software current, we don't really recommend installing your own Python given how we have to interact with it. You may experience other odd issues that will be even harder to diagnose...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun May 23, 2021 11:11 am
Hackencrash offline
User avatar
Posts: 251
Joined: Dec 16, 2015
Location: UK

Re: How to install python modules in Indigo 7

To answer the question: How to install python modules in Indigo 7

1. Open the Terminal app on your Mac running Indigo.

2. First, ensure Pip is installed by typing:
sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python -m ensurepip --default-pip

3. Then, install your Python module(s) by typing:
sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python -m pip install yourmodule

This will ensure the modules get correctly installed into:
/Library/Python/2.7/site-packages/

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests