No module named ‘fcntl’ Python import gpiod

Hello,
I trying to use: import gpiod for my python project
But i struggle w/ following Error Message
ModuleNotFoundError: No module named ‘fcntl’

Using Torizon Core with Containers on iMX8

Can somebody help?

Thank you

Hi @Abfuellwelt001 ,

Can you provide more details about your issue?

  • What version of TorizonCore are you using? Are you using an Apalis iMX8?
  • What steps did you do to receive the error message? Can you show the source code of your project?
  • Are you using our VSCode IDE extension V2?
  • Are you using Windows or a Linux distro as your host PC?

Best regards,
Lucas Akira

Hello,

that is what I am using:

Hardware:
Apalis iMX8QP 2GB V1.1C w/ Ixora V1.2A carrier board
Installed Operating system
TorizonCore with evaluation containers

I just created a test project for Python coding. The source code is just import gpiod.
Once I try to RUN this w/ VSCode i get this error message.

Following import is working w/o any error message
from pymodbus.client import ModbusTcpClient

On my host i am using Windows

Best regards

Hi @Abfuellwelt001 ,

how are you running the project? On your host or already on the module?

If you’re running it directly on the module in a container then you have to make sure that the package is available in the container.

On the host since you are on Windows it appears that this package is not available.

Or am I not understanding the issue right?

Best Regards
Kevin

Hello,

i did everything like mentioned under the following link

I added under extrapackages “python3-gpiod” and installed gpiod on the host.
The import gpiod is recognized by VS Code but once I click RUN in VS Code I am getting the error message in VS Code Window.

Kind regards

Hi @Abfuellwelt001 ,

TorizonCore with evaluation containers

I meant the version number of TorizonCore like 5.7.2 or 6.2.0. You can check that by running the command below on the Apalis iMX8:

cat /etc/os-release

I added under extrapackages “python3-gpiod” and installed gpiod on the host.

You don’t need to install gpiod on your host PC in order to run the code on the SoM. It should be enough to add python3-libgpiod in extrapackages.

As @kevin.tx pointed out, fcntl is not available on Windows. It looks like the code is accidentally running on the Windows host machine.


You’re using V1 of our IDE extension, which is an older release that we don’t plan to add new features.

Can you try creating a new Python project on V2 instead? We remade the extension from the ground up and it should be a better overall experience compared to V1. Please follow the resources on this page IDE Extension | Toradex Developer Center to set it up.

Best regards,
Lucas Akira