Adding additional python libraries AppDaemon

Hi all,

Does anyone know how i can use additional python libraries?
Using HassIO with AppDaemon and trying to import pycurl for example.
I get a message that this module is not available, but how can i add this??

1 Like

You need to include it in the python_packages portion of the add-on config:

{
  "log_level": "info",
  "system_packages": [],
  "python_packages": [
    "pycurl"
  ]
}
1 Like

Thanks for the quick response, looks like this is what i was searching for.

Tried to add the package but i guess it needs additional system packages.

[cont-init.d] 81-python-packages.sh: executing... 
Collecting pycurl
  Downloading https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz (214kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/tmp/pip-install-ogq2_2au/pycurl/setup.py", line 223, in configure_unix
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
        restore_signals, start_new_session)
      File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'curl-config': 'curl-config'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-ogq2_2au/pycurl/setup.py", line 913, in <module>
        ext = get_extension(sys.argv, split_extension_source=split_extension_source)
      File "/tmp/pip-install-ogq2_2au/pycurl/setup.py", line 582, in get_extension
        ext_config = ExtensionConfiguration(argv)
      File "/tmp/pip-install-ogq2_2au/pycurl/setup.py", line 99, in __init__
        self.configure()
      File "/tmp/pip-install-ogq2_2au/pycurl/setup.py", line 227, in configure_unix
        raise ConfigurationError(msg)
    __main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory: 'curl-config': 'curl-config'

right, pycurl needs a lot of extra.
there where more attempts from people here on the forum, and it took them a while to figure out what all was needed.

Any solution to have my own package used instead ? Any way for instance to copy past the content of my site-package to the one fetch by AD ?

Hi there. Just been through this myself for a custom python app. The solution to pycurl is here Dahua IPC to MQTT App - #55 by xbmcnut

1 Like

@xbmcnut
That was what i tried to acchieve, but i was missing the pycurl library inside the AppDaemon apps. I’ve searched for the packages needed and this is how i got it working:

{
  "log_level": "debug",
  "system_packages": [
    "curl-dev",
    "python3-dev",
    "libressl-dev",
    "musl-dev",
    "gcc",
    "libcurl"
  ],
  "python_packages": [
    "pycurl"
  ]
}

When it worked i started rewriting the application since i do not use mqtt, but just want to notify my devices including a snapshot

What my setup does is the following:

  • Camera has an event (CrossLineDetection for example), takes a snapshot and stores it on a share
  • AppDaemon reads camera events and get triggered with the help of pycurl
  • AppDaemon takes the event time from the camera data and uses this to find the correct snapshot
  • AppDaemon calls the notify services and send the snapshot including information to my tv’s and phones

My previous setup was getting the snapshot from the camera directly, but sometimes the object was already gone so this was no option for me.