question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FileNotFoundError: (...) /usr/local/lib/python3.8/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein

See original GitHub issue

I am running Ubuntu Server 20.04 LTS 64-bit on a Raspberry Pi 3 B. I have a DHT11 sensor module.

I am following the instructions from https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/python-setup but the code does not work for me.

I have successfully executed these commands beforehand:

sudo apt-get install libgpiod2
sudo pip3 install adafruit-circuitpython-dht

This is my code:

# ky015.py
import time
import board
import adafruit_dht

# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT11(board.D3)

while True:
    try:
        # Print the values to the serial port
        temperature_c = dhtDevice.temperature
        temperature_f = temperature_c * (9 / 5) + 32
        humidity = dhtDevice.humidity
        print(
            "Temp: {:.1f} F / {:.1f} C    Humidity: {}% ".format(
                temperature_f, temperature_c, humidity
            )
        )

    except RuntimeError as error:
        # Errors happen fairly often, DHT's are hard to read, just keep going
        print(error.args[0])

    time.sleep(2.0)

This is the error I get:

ubuntu@ubuntu:~/ky015$ sudo python3 ky015.py
Traceback (most recent call last):
  File "ky015.py", line 6, in <module>
    dhtDevice = adafruit_dht.DHT11(board.D3)
  File "/usr/local/lib/python3.8/dist-packages/adafruit_dht.py", line 263, in __init__
    super().__init__(True, pin, 18000)
  File "/usr/local/lib/python3.8/dist-packages/adafruit_dht.py", line 69, in __init__
    self.pulse_in = PulseIn(self._pin, 81, True)
  File "/usr/local/lib/python3.8/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py", line 65, in __init__
    self._process = subprocess.Popen(cmd)
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein'

I have also followed the instructions for “Setup your Linux Board for using CircuitPython Libraries”. The script blinkatest.py completes successfully (Link to code: https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi#blinka-test-3-15). Output:

ubuntu@ubuntu:~/ky015$ sudo python3 blinkatest.py
Hello blinka!
Digital IO ok!
I2C ok!
SPI ok!
done!

The file libgpiod_pulsein does exist. The Python code seems to try and run it with subprocess.Popen. That’s strange IMHO since the “lib” prefix does imply that it is a library, not an executable, right? On the other hand, a library should have a suffix of “.so”. I am dumbfounded by that file name. By the way, this is ldd output for the file:

ubuntu@ubuntu:/usr/local/lib/python3.8/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio$ ldd libgpiod_pulsein
        not a dynamic executable

This is the stat output:

ubuntu@ubuntu:/usr/local/lib/python3.8/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio$ stat libgpiod_pulsein
  File: libgpiod_pulsein
  Size: 19752           Blocks: 40         IO Block: 4096   regular file
Device: b302h/45826d    Inode: 391704      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (   50/   staff)
Access: 2020-05-05 10:00:24.194643069 +0000
Modify: 2020-05-05 10:00:10.230685234 +0000
Change: 2020-05-05 10:00:10.990682910 +0000
 Birth: -

I have tried to reinstall the packages, but it did not fix my problem.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

16reactions
goldyfruitcommented, Aug 10, 2020

It seems to be related to 64-bits. I’m running Ubuntu 20.04 64-bits on my RPi 4B, and the libgpiod_pulsein library shipped with adrafruit_blinka Python package is 32-bits.

$ file ~/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein
/home/ubuntu/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=356bb870cf3f5a35b0862d12a708b782a9c365f6, not stripped

So basically I had to recompile the library for arm64 architecture, here are the steps:

$ sudo apt install libgpiod-dev git build-essential
$ git clone https://github.com/adafruit/libgpiod_pulsein.git
$ cd libgpiod_pulsein/src
$ make
$ cp libgpiod_pulsein ~/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein
3reactions
c4explosivecommented, May 31, 2021

It seems to be related to 64-bits. I’m running Ubuntu 20.04 64-bits on my RPi 4B, and the libgpiod_pulsein library shipped with adrafruit_blinka Python package is 32-bits.

$ file ~/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein
/home/ubuntu/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=356bb870cf3f5a35b0862d12a708b782a9c365f6, not stripped

So basically I had to recompile the library for arm64 architecture, here are the steps:

$ sudo apt install libgpiod-dev git build-essential
$ git clone https://github.com/adafruit/libgpiod_pulsein.git
$ cd libgpiod_pulsein/src
$ make
$ cp libgpiod_pulsein ~/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein

This works, thanks. Working on manjaro for raspberry PI 3B.

Read more comments on GitHub >

github_iconTop Results From Across the Web

open() gives FileNotFoundError/IOError: Errno 2 No such file ...
Call os.chdir(dir) , dir being the folder where the file is located, then open the file with just its name like you were...
Read more >
Python FileNotFoundError: [Errno 2] No such file or directory ...
This error tells you that you are trying to access a file or folder that does not exist. To fix this error, check...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found