bastienleonard / pysensors

Easy Linux hardware monitoring in Python
https://bastienleonard.github.io/pysensors
Other
29 stars 8 forks source link

Unable to install inside the Docker container #7

Closed strange-v closed 3 years ago

strange-v commented 3 years ago

Hi.

It's a really cool project and it works nice but not in the docker container. For some reason, I'm getting error during installation:

Collecting PySensors
  Downloading PySensors-0.0.4.tar.gz (10 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6sdmbvy5/pysensors/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6sdmbvy5/pysensors/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-3xslclh3
         cwd: /tmp/pip-install-6sdmbvy5/pysensors/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-6sdmbvy5/pysensors/setup.py", line 3, in <module>
        import sensors
      File "/tmp/pip-install-6sdmbvy5/pysensors/sensors/__init__.py", line 20, in <module>
        raise ImportError("can't find the sensors library.")
    ImportError: can't find the sensors library.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Part of my dockerfile:

FROM python:3.8.5-alpine
RUN apk add build-base linux-headers ethtool zlib-dev jpeg-dev freetype-dev
RUN pip3 install wheel luma.core luma.oled psutil PySensors

I'm not closely familiar with docker and python, so maybe the issue isn't related to the library itself.

bastienleonard commented 3 years ago

I think there are two issues:

Here is a docker file that works for this project:

FROM python:3.8.5-alpine
RUN apk add git build-base bison flex

RUN git clone https://github.com/lm-sensors/lm-sensors.git /lmsensors && \
    cd /lmsensors && make install && \
    git clone https://github.com/bastienleonard/pysensors.git /pysensors && \
    cd /pysensors && python setup.py build_ext --inplace

WORKDIR /pysensors
CMD ["python", "-c", "import sensors; print(sensors.get_detected_chips())"]

I’m installing lm_sensors from GitHub because I couldn’t figure out how to get the headers otherwise.

strange-v commented 3 years ago

Thank you, I'll try to install it in this way.

bastienleonard commented 3 years ago

Please reopen if you still face issues.