Including Python Getpass Library

I’m working with a python library (clickhouse_connect) that depends on getpass, a standard python library. I’m deploying that library to an embedded linux device, a Toradex iMX8QXP board. When I go to import the library from the Python3 command-line interpreter, I get a “module not found” error.

Getpass is a standard library in python, so I shouldn’t need to include anything in the local.conf file to include it. I’ve tested that I can see other standard library items like asyncio and datetime. I also tried to import getpass from the console itself to ensure that something in clickhouse wasn’t blocking the import.

I looked through the getpass documentation, and I see that the only reason getpass might not be included is if the device is running in WebAssembly:

This module does not work or is not available on WebAssembly. See WebAssembly platforms for more information.

I don’t know how to determine if my device is acting like a WebAssembly platform. The above seems like the most likely culprit though.

Does anyone know a workaround for this? Anything I can add in the yocto build to allow getpass to import?

System Configuration:

  • OS Image: built in Yocto based on Toradex reference multimedia image

  • Python Version: 3.12.10, from meta-python

  • Yocto Build: Scarthgap

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Python Module Availability in Yocto Builds

The issue you’re experiencing with the getpass module not being available is likely related to the minimal Python installation that Yocto provides by default(1). This is not related to WebAssembly - your iMX8QXP board is running standard ARM Linux.

Solution: Include Complete Python Standard Library

The most effective solution is to add python3-modules to your Yocto build, which includes all standard library modules that aren’t included in the minimal Python3 installation(2).

In your local.conf file, add(1):

IMAGE_INSTALL_append = "python3-modules"

(1)

Additional Recommended Packages

For a more complete Python development environment, you may also want to include(2):

IMAGE_INSTALL_append = "python3-modules packagegroup-core-buildessential python3-venv python3-dev"

These additional packages provide:

  • packagegroup-core-buildessential: Build tools for compiling Python modules
  • python3-venv: Virtual environment support
  • python3-dev: Development headers for Python

Alternative: Targeted Package Installation

If you prefer a more minimal approach, you can search for the specific package containing getpass using(1):

find ./layers -name "*python*getpass*bb"

(1)

However, since getpass is part of the core Python standard library, the python3-modules approach is recommended.

Verification

After rebuilding your image with these changes, you should be able to import getpass and use your clickhouse_connect library without issues. The python3-modules package ensures that all standard library modules are available, resolving the “module not found” error you’re encountering.

Best regards, Toradex AI Assistant.

I tried these steps, but still ran into the same issue. Even with the python3-modules did it fail.

Edit: I actually did figure this out. It seems that I made some mistake in the python loading process. When I added python3-modules, the error went away (although there are now a slew of other dependencies…).