Importing modules witin python plugin

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!
Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
Ewaldharmsen
Posts: 52
Joined: Tuesday 07 February 2017 16:00
Target OS: Linux
Domoticz version:
Contact:

Importing modules witin python plugin

Post by Ewaldharmsen » Friday 09 November 2018 18:23

Domoticz Version: 4.10181
Platform: RPI3

Description:
I am working on a python plugin based on pychromecast.
I did a normal install using

Code: Select all

sudo python3 -m pip install pychromecast
When I open up python3 I can import and use pychromecast just like it should.

However when doing

Code: Select all

import pychromecast
in the plugin I get this error:
2018-11-09 17:13:40.117 Error: (Chromecast) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Chromecast/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-11-09 17:13:40.117 Error: (Chromecast) Module Import failed, exception: 'ImportError'
2018-11-09 17:13:40.118 Error: (Chromecast) Module Import failed: ' Name: pychromecast'
Changing

Code: Select all

import pychromecast
to

Code: Select all

import sys
sys.path.append('/usr/local/lib/python3.5/dist-packages')
import pychromecast
Does not help.

In the end I ended up installing pychromecast and all its dependencies manually via

Code: Select all

sudo python3 -m pip install pychromecast -t /usr/lib/python3.5
But this is very ugly.
Anybody a clue how I can make Domoticz check /usr/local/lib/python3.5/dist-packages as well?

Post Reply

Who is online

Users browsing this forum: hennykarreman and 0 guests