tpm2-software / tpm2-pytss

Python bindings for TSS
https://tpm2-pytss.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
62 stars 45 forks source link

Error on import #349

Open ludovicpeyter opened 2 years ago

ludovicpeyter commented 2 years ago

Hello,

I've been trying to use that library for a while by now, but every time I run my script, I get the following error:

ImportError: /home/pi/.local/lib/python3.9/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so: undefined symbol: Tss2_MU_TPML_TAGGED_POLICY_Unmarshal

I'm working on a Raspberry Pi, but I don't think it's linked to the error.

Thanks already for your future answer.

whooo commented 2 years ago

Seem that the wheel from pypi is built against a newer version of tpm2-tss, can you run apt show libtss2-dev and check which version you have on your system?

How did you install tpm2-pytss?

ludovicpeyter commented 2 years ago

I've tryed different ways, but I guess it was with python3 -m pip install tpm2-pytss, or maybe with pip3 install tpm2-pytss. Is there any difference between these two ? For your other question about libtss2-dev version, on my VM I have version 3.2.0-1, and on my Raspberry Pi I have version 3.0.3-2.

whooo commented 2 years ago

Could you run: cat : /home/pi/.local/lib/python3.9/site-packages/tpm2_pytss/internal/versions.py Also, when you installed it, do you recall if it built the bindings?

ludovicpeyter commented 2 years ago

VM: _versions = { "tss2-esys": "3.2.0", "tss2-fapi": "3.2.0",

} RPi: No such file or directory

Sorry but i can't recall about the installation.

whooo commented 2 years ago

Just to be clear, it works on the VM but not on the RPi? can you run pip show tpm2-pytss

ludovicpeyter commented 2 years ago

I got a different error on the VM so I'm not sure if if it really did work... On the VM I have version 1.1.0 and on the RPi version 1.0.0

whooo commented 2 years ago

could you test a pip install --upgrade tpm2-pytss I'm not sure why the module is built for a newer version of tpm2-tss then you have on the system

ludovicpeyter commented 2 years ago

I got that error while installing upgrade: ERROR: Command errored out with exit status 1: command: /usr/bin/python3 /tmp/tmpuqd6k3hb_in_process.py prepare_metadata_for_build_wheel /tmp/tmp823jicre cwd: /tmp/pip-install-jb41sd4l/tpm2-pytss_becebfc8bb204ba8a05bad3981b529fb When I check the details, it says that the file /usr/include/aarch64-linux-gnu/tss2/tss2_common.h doesn't exist.

whooo commented 2 years ago

Do you have the package libtss-dev installed? If yes, could you remove it for now and try again

ludovicpeyter commented 2 years ago

It worked, thank you very much, I wouldn't have found that alone.

ludovicpeyter commented 2 years ago

Seems I talked too soon, I could upgrade tpm2-pytss, but the error remains when I try to import the library.

whooo commented 2 years ago

Could you check the versions,py file again?

ludovicpeyter commented 2 years ago

Now I have this content : _versions = { "tss2-esys": "3.0.3", "tss2-fapi": "3.0.3",

}

whooo commented 2 years ago

then it should have been built towards the version on your system and should work, do you get the exact same error?

ludovicpeyter commented 2 years ago

Yeah: ImportError: /home/pi/.local/lib/python3.9/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so: undefined symbol: Tss2_MU_TPML_TAGGED_POLICY_Unmarshal

whooo commented 2 years ago

Could you run: ldd /home/pi/.local/lib/python3.9/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so and ls -ld /home/pi/.local/lib/python3.9/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so

ludovicpeyter commented 2 years ago

What infos do you need from the ldd command ?

ludovicpeyter commented 2 years ago

Here is the result for ls -ld: -rwxr-xr-x 1 pi pi 3297320 Apr 29 13:29 /home/pi/.local/lib/python3.9/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so

whooo commented 2 years ago

What infos do you need from the ldd command ?

The full output if possible, I'm mostly interested in if it uses the same libraries during runtime and compilation time

ludovicpeyter commented 2 years ago

linux-vdso.so.1 (0x0000007fb556b000) libtss2-esys.so.0 => /lib/aarch64-linux-gnu/libtss2-esys.so.0 (0x0000007fb5392000) libtss2-tctildr.so.0 => /lib/aarch64-linux-gnu/libtss2-tctildr.so.0 (0x0000007fb537b000) libtss2-rc.so.0 => /lib/aarch64-linux-gnu/libtss2-rc.so.0 (0x0000007fb5363000) libtss2-mu.so.0 => /lib/aarch64-linux-gnu/libtss2-mu.so.0 (0x0000007fb530b000) libtss2-fapi.so.1 => /lib/aarch64-linux-gnu/libtss2-fapi.so.1 (0x0000007fb522e000) libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007fb51fd000) libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007fb5087000) /lib/ld-linux-aarch64.so.1 (0x0000007fb553b000) libcrypto.so.1.1 => /lib/aarch64-linux-gnu/libcrypto.so.1.1 (0x0000007fb4dd9000) libtss2-sys.so.1 => /lib/aarch64-linux-gnu/libtss2-sys.so.1 (0x0000007fb4da7000) libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007fb4d93000) libjson-c.so.5 => /lib/aarch64-linux-gnu/libjson-c.so.5 (0x0000007fb4d72000) libcurl.so.4 => /lib/aarch64-linux-gnu/libcurl.so.4 (0x0000007fb4cce000) libnghttp2.so.14 => /lib/aarch64-linux-gnu/libnghttp2.so.14 (0x0000007fb4c93000) libidn2.so.0 => /lib/aarch64-linux-gnu/libidn2.so.0 (0x0000007fb4c63000) librtmp.so.1 => /lib/aarch64-linux-gnu/librtmp.so.1 (0x0000007fb4c36000) libssh2.so.1 => /lib/aarch64-linux-gnu/libssh2.so.1 (0x0000007fb4bf4000) libpsl.so.5 => /lib/aarch64-linux-gnu/libpsl.so.5 (0x0000007fb4bd2000) libssl.so.1.1 => /lib/aarch64-linux-gnu/libssl.so.1.1 (0x0000007fb4b35000) libgssapi_krb5.so.2 => /lib/aarch64-linux-gnu/libgssapi_krb5.so.2 (0x0000007fb4ad7000) libldap_r-2.4.so.2 => /lib/aarch64-linux-gnu/libldap_r-2.4.so.2 (0x0000007fb4a72000) liblber-2.4.so.2 => /lib/aarch64-linux-gnu/liblber-2.4.so.2 (0x0000007fb4a53000) libbrotlidec.so.1 => /lib/aarch64-linux-gnu/libbrotlidec.so.1 (0x0000007fb4a38000) libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007fb4a0e000) libunistring.so.2 => /lib/aarch64-linux-gnu/libunistring.so.2 (0x0000007fb4882000) libgnutls.so.30 => /lib/aarch64-linux-gnu/libgnutls.so.30 (0x0000007fb4662000) libhogweed.so.6 => /lib/aarch64-linux-gnu/libhogweed.so.6 (0x0000007fb460a000) libnettle.so.8 => /lib/aarch64-linux-gnu/libnettle.so.8 (0x0000007fb45b7000) libgmp.so.10 => /lib/aarch64-linux-gnu/libgmp.so.10 (0x0000007fb452f000) libgcrypt.so.20 => /lib/aarch64-linux-gnu/libgcrypt.so.20 (0x0000007fb445f000) libkrb5.so.3 => /lib/aarch64-linux-gnu/libkrb5.so.3 (0x0000007fb4375000) libk5crypto.so.3 => /lib/aarch64-linux-gnu/libk5crypto.so.3 (0x0000007fb4337000) libcom_err.so.2 => /lib/aarch64-linux-gnu/libcom_err.so.2 (0x0000007fb4323000) libkrb5support.so.0 => /lib/aarch64-linux-gnu/libkrb5support.so.0 (0x0000007fb4304000) libresolv.so.2 => /lib/aarch64-linux-gnu/libresolv.so.2 (0x0000007fb42dd000) libsasl2.so.2 => /lib/aarch64-linux-gnu/libsasl2.so.2 (0x0000007fb42b1000) libbrotlicommon.so.1 => /lib/aarch64-linux-gnu/libbrotlicommon.so.1 (0x0000007fb4280000) libp11-kit.so.0 => /lib/aarch64-linux-gnu/libp11-kit.so.0 (0x0000007fb4131000) libtasn1.so.6 => /lib/aarch64-linux-gnu/libtasn1.so.6 (0x0000007fb410b000) libgpg-error.so.0 => /lib/aarch64-linux-gnu/libgpg-error.so.0 (0x0000007fb40d8000) libkeyutils.so.1 => /lib/aarch64-linux-gnu/libkeyutils.so.1 (0x0000007fb40c3000) libffi.so.7 => /lib/aarch64-linux-gnu/libffi.so.7 (0x0000007fb40aa000)

whooo commented 2 years ago

Wat does pkg-config --cflags --libs tss2-mu tell you? It's sadly hard to debug this remotely, is there anything else about your setup that would be good to know? such as running in a venv, having other versions of tpm2-tss on the system etc

ludovicpeyter commented 2 years ago

-I/usr/include/tss2 -ltss2-mu I don't even know what a venv is. And I have done the same configuration on both my RPi and VM.

whooo commented 2 years ago

Right, as your VM has a newer version of tpm2-tss it works as Tss2_MU_TPML_TAGGED_POLICY_Unmarshal was added in version 3.1, the question is why the compiled bindings on your Pi are linked/built to a newer version of tpm2-tss then you have on your system