Python Plugins: Site Package directories added to default Python path

Python and python framework

Moderator: leecollings

Post Reply
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Python Plugins: Site Package directories added to default Python path

Post by Dnpwwo »

After recently discovering that behind the scenes Python normally pre-loads the 'site' module and appends additional packages to the Python path, I have pushed a change tonight to make the Python Plugin Framework do the same.

Hopefully the change will make the framework mimic 'normal' Python better and avoid confusion.

Framework now effectively does this prior to the plugin load:

Code: Select all

import site
for site in site.getsitepackages():
    sys.path.append(site)
so that you don't have to to use packages installed with pip to the system. On linux you need to use 'sudo pip3...'

This will be in the next beta.
Last edited by Dnpwwo on Saturday 20 April 2019 3:07, edited 1 time in total.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
zak45
Posts: 954
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugins: Site Package directories added to default Python path

Post by zak45 »

Great news.
thanks!
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugins: Site Package directories added to default Python path

Post by pipiche »

That is very cool !
pipiche
Posts: 2035
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugins: Site Package directories added to default Python path

Post by pipiche »

@dnpwwo any idea since which version of Domoticz it is implemented ?
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugins: Site Package directories added to default Python path

Post by Dnpwwo »

Sorry, I don't.

Maybe you could work it out from the date of the post?
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Post Reply