How to install working Pycurl? (needed for a component)

Hello, I’m trying to use a component that require Pycurl >= 7 (I’m using hassbian), but I’ve always error because HA doesn’t see pycurl. I tried to install it from pip3 (logged in ssh as homeassistant) and from apt-get (python3-pycurl, logged in ssh as pi), always this error. Anyone could help me?

p.s. the custom components I’m trying to use is this one (Dahua event by SaWey)

Error loading custom_components.dahua_event. Make sure all dependencies are installed
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py”, line 142, in get_component
module = importlib.import_module(path)
File “/usr/lib/python3.5/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 986, in _gcd_import
File “”, line 969, in _find_and_load
File “”, line 958, in _find_and_load_unlocked
File “”, line 673, in _load_unlocked
File “”, line 673, in exec_module
File “”, line 222, in _call_with_frames_removed
File “/home/homeassistant/.homeassistant/custom_components/dahua_event.py”, line 10, in
import threading, logging, os, socket, pycurl, time
ImportError: No module named ‘pycurl’

Thank you!

You need to activate the virtual environment as well as logging in as user homeassistant before running pip install.

I think I’m not able to do it. Could you help me please?

I have a virtual environment (“virtualenv --version” said me version 15.1) by default with hassbian so I think I don’t need this HA guide.

I only need to go to /srv/homeassistant (I think this is the virtualenv folder, isn’t it?) logging as homeassistant and use here the pip3 installation command? Is it so simple? :thinking:

Thank you @gpbenton

sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate

That will change to the right user, then activate the venv

Thank you very much! You’re my hero! :call_me_hand:

p.s. for any other users, the first command need to be “sudo su -s /bin/bash homeassistant”

:man_facepalming: Fixed that, sorry!

1 Like

I’m also trying to install the same Dahua event component that eporedieis mentions here, but under HASSIO as a local add-on. I’m having difficulty getting pycurl to install as well. The error msg is “The command ‘/bin/sh -c pip3 install pycurl’ returned a non-zero code: 1”

I’m not entirely sure what prerequisites have to be installed first, but here’s what I have so far. (Some of these libraries may not be needed, and were best guesses). Does anyone have any advice on how to install pycurl in a HASSIO Dockerfile?

ARG BUILD_FROM
FROM $BUILD_FROM
ENV LANG C.UTF-8
ENV PYCURL_SSL_LIBRARY=openssl
   
RUN apk add --no-cache -U \
        python3 \
        python3-dev \
        curl \
        libcurl \
        openssl \
        && pip3 install --no-cache --upgrade pip

 RUN pip3 install pycurl

COPY dahua_event.py /
RUN chmod a+x /dahua_event.py
ENTRYPOINT ["python3", "/dahua_event.py"]

Did you ever get that working? I’m trying a fork of that and coming up with the same Pycurl issues.

No, sadly I did not make any further progress and set it aside hoping there would be a Dahua addon with full event capability eventually. A big part of the problem is I have had no experience in creating a forked component for Hassio.

If you come up with a solution for the pycurl install on Hassio I would be happy to help you test it.

Working on a solution over here Dahua IPC to MQTT App

This is the working config for AppDaemon that will install pycurl.

{
  "log_level": "info",
  "system_packages": [
    "libcurl",
    "python3-dev",
    "curl-dev",
    "g++"
  ],
  "python_packages": [
    "pip==19.0.2",
    "pycurl"
  ]
}
1 Like

Hey, that’s good news you found the right mix of packages to install for pycurl!

I’m currently not using Appdaemon, as good ol’ Yaml automation does all I need (so far). I’ll see if I can find time to get this to work with Hassio without Appdaemon first.

I have it working now, at least on video motion events. I’ve not tweaked the config in the hope that I can get the wire cross detection working.

Using the custom_deps addon I was able to install pycurl, thus:

{
  "pypi": [
    "pycurl"
  ],
  "apk": [
    "curl",
    "libcurl",
    "python3-dev",
    "curl-dev",
    "g++"
  ]
}

Hello @mindsocket,

exactly, where should put the lines ?, I have no clear path ‘custom_deps addon’

Thanks

I have it !!, the repo necessary I have not installed