Skip to content

cryptography ImportError #3329

Closed
Closed

Description

@GvozdevLeonid

I get an error when launching the application

File "home/runner/work/Helios/Helios/.buildozer/android/platform/build-arm64-v8a/build/python-installs/Helios/arm64-v8a/cryptography/hazmat/primitives/_serialization.py", line 10, in <module>
  File "home/runner/work/Helios/Helios/.buildozer/android/platform/build-arm64-v8a/build/python-installs/Helios/arm64-v8a/cryptography/hazmat/primitives/hashes.py", line 9, in <module>
ImportError: dlopen failed: cannot locate symbol "PyExc_MemoryError" referenced by "/data/data/org.gleo.helios/files/app/_python_bundle/site-packages/cryptography/hazmat/bindings/_rust.abi3.so"...

The build is completed successfully. I didn't change the configuration or recipes. Tell me where to dig

buildozer = 1.5.0
python for android = dev ( but im using my fork)
python = 3.11.9

Activity

  1. T-Dynamos commented on May 12, 2026

    @T-Dynamos
    Member

    It cannot find PyExc_MemoryError which usually is in libpython. Maybe you can confirm this symbol exists in libpython produced by your build env with nm maybe.

  2. GvozdevLeonid commented on May 12, 2026

    @GvozdevLeonid
    ContributorAuthor

    I solved the problem by adding the flag in CryptographyRecipe

    python_link_version = self.ctx.python_recipe.link_version
    env["RUSTFLAGS"] += f" -Clink-arg=-lpython{python_link_version}"
    
  3. b3b commented on May 17, 2026

    @b3b
    Contributor

    I have the same issue, but with a different missing symbol: _Py_TrueStruct

    Reproduced it outside my app with: p4a create --dist_name=crypto_test --bootstrap=sdl2 --sdk-dir="$ANDROIDSDK" --ndk-dir="$ANDROIDNDK" --ndk-api=22 --android-api=36 --ignore-setup-py --requirements=python3==3.14.2,hostpython3==3.14.2,cryptography --arch=arm64-v8a --copy-libs --debug

    The resulting _rust.abi3.so is not linked against libpython, checked with:

    find ~/.local/share/python-for-android/ -name '_rust.abi3.so' -exec readelf -d {} \; | grep libpython

    Adding libpython link args via RUSTFLAGS in the cryptography recipe fixed it for me.

  4. CluckyMedia commented on May 18, 2026

    @CluckyMedia

    I solved the problem by adding the flag in CryptographyRecipe

    python_link_version = self.ctx.python_recipe.link_version
    env["RUSTFLAGS"] += f" -Clink-arg=-lpython{python_link_version}"
    

    Where to add the flag? Where is CryptographyRecipe? I use buildozer on a github runner. Thanks

  5. T-Dynamos commented on May 18, 2026

    @T-Dynamos
    Member

    Recipe is in: pythonforandroid/recipes/cryptography/__init__.py

    This is an open issue - not yet fixed in develop.

    For now you can use p4a locally with modified files or use fork.

  6. CluckyMedia commented on May 18, 2026

    @CluckyMedia

    I will wait till the issue is fixed, hopefully it is not far off. Thanks

  7. added
    Priority: HighAfter critical issues are fixed, these should be dealt with before any further issues.
    and removed
    Priority: MediumThis issue may be useful, and needs some attention.
    on May 18, 2026
  8. CluckyMedia commented on May 21, 2026

    @CluckyMedia

    Are many developers working on this codebase?

  9. T-Dynamos commented on May 21, 2026

    @T-Dynamos
    Member

    @CluckyMedia Issue is fixed in #3333, You can test by setting p4a.branch = issue-3329.

    Are many developers working on this codebase?

    P4A's core team is relatively small - most of us are volunteers balancing this with daily jobs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: HighAfter critical issues are fixed, these should be dealt with before any further issues.easy

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions