ImportError: No module named zymkey

Completed install. 3sec LED is flashing. Attempted to run test scripts and encountered error. Attempted to manually install module and it failed.

How do I install the python module zymkey?

python /usr/local/share/zymkey/examples/zk_app_utils_test.py
Traceback (most recent call last):
File “zk_app_utils_test.py”, lwine 1, in
import zymkey
ImportError: No module named zymkey

sudo pip install zymkey
Collecting zymkey
Downloading https://files.pythonhosted.org/packages/39/82/32629bfc4c2a8d048bec0eb22a3be07178d42a7a39d9b68e495fd91bef99/zymkey-0.1.3.tar.gz


python /usr/local/share/zymkey/examples/zk_app_utils_test.py
Traceback (most recent call last):
File “/usr/local/share/zymkey/examples/zk_app_utils_test.py”, line 1, in
import zymkey
File “/usr/local/lib/python2.7/dist-packages/zymkey/init.py”, line 3, in
from .module import Zymkey
File “/usr/local/lib/python2.7/dist-packages/zymkey/module.py”, line 50, in
raise ZymkeyLibraryError(‘unable to find {}, checked {}’.format(os.path.basename(ZYMKEY_LIBRARY_PATH), prefixes))
zymkey.exceptions.ZymkeyLibraryError: unable to find libzk_app_utils.so, checked [’/usr/lib/python2.7/dist-packages/usr/local/lib’, ‘/usr/local/lib’]

Please close the ticket. I have found a solution but not a cause. I am answering my own message post.

I tried the zymbit software install on another Pi and the zymkey error didn’t occur. I did another complete Pi and zymbit install and the error appeared again.

After I encountered the error, I ran the zymbit install a second time. The output from the install didn’t enlighten me because it found all the software components it was trying to install. When I ran the python scripts they worked.

I have the output from the failed install (i.e. zymkey error) and the output after the second run if this is of value.

The ironic part is the install has worked sometimes without having to run the install twice. I can’t figure out what is missing to cause this to happen.

If you get the zymkey module error just try running the zymkey install a second time and see if it provides you success.

Sean

@colporteur - which version/release of Raspian are you using ? (we think it could be version related…)

Sorry for the delay. I have been away from my lab. Raspbian Stretch Lite 2019-04-08

Sean

I had an epiphany and tried another version of python. No success:)

python3 /usr/local/share/zymkey/examples/zk_app_utils_test.py
Exception ignored in: <bound method Zymkey.del of <zymkey.module.Zymkey object at 0x769ee1d0>>
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/zymkey/module.py”, line 74, in del
raise AssertionError(‘bad return code {!r}’.format(ret))
AssertionError: bad return code -1
Testing data lock…
Traceback (most recent call last):
File “/usr/local/share/zymkey/examples/zk_app_utils_test.py”, line 6, in
dst = zymkey.client.lock(src)
AttributeError: ‘NoneType’ object has no attribute ‘lock’

were you able to fix the problem? I have the same problem now.

I have the exact same problem here and regardless I many times I re-install the script it doesn’t work. @vidya were you able to finally solve it?

@imanolgo - It sounds like your installation was not completed successfully. Details for installation are here: Getting Started.

Can you give me a few more details? Which PI are you using and which OS? What is the blue LED of the Zymkey doing? It should be flashing once every 3 seconds, and what is the output of “systemctl status zkifc”?

Bob

@Bob_of_Zymbit I’m currently using a Raspberry Pi 4 running the latest Raspbian GNU/Linux 10 (buster). I’ve checked that I2C is enabled with other I2C devices (since the Zymkey doesn’t show up with i2cdetect). I’ve also used this link to install all the dependencies.

curl -G https://s3.amazonaws.com/zk-sw-repo/install_zk_sw.sh | sudo bash

Also, the Zimkey light is flashing regularly every 3 seconds. Finally, the service zkifc is running properly.

However, libzk_app_utils.so was installed under /usr/lib/ and I had to move it to /usr/local/lib so the python library could find it. And this is the error that I get:

libzk_app_utils.so: undefined symbol: zkSetGMTTime

Please let me know if you have any idea what it could be.

@imanolgo - The only thing you need to do to install is the curl command. That should install the library file and python module in the correct locations. libzk_app_utils.so should be in /usr/lib, not /usr/local/lib.

Did you do any additional steps? The previous user in this thread unnecessarily did a “pip install zymkey” which would pull in old code and most likely break things.To fix, I think you can just do “pip uninstall zymkey” and mv libzk_app_utils.so back to /usr/lib. Or to be safe, start over and only use the curl command.

Please let me know if I have that wrong and we can troubleshoot in more detail.

Bob

1 Like

@Bob_of_Zymbit That worked like a charm. I thought you had to install the python library using pip.
Thanks for the quick reply.

Hi @Bob_of_Zymbit and @Phil_of_Zymbit

I’m facing exactly the same issue on 3 different Raspberry Pi Model 4B, running Debian 11 (Bullseye) 64 bits.

The Zimkey light is flashing regularly every 3 seconds. Finally, the service zkifc is running properly, so all good on that side.

I’ve followed the guide by the book, launched the following curl bash command as requested:
curl -G http://s3.amazonaws.com/zk-sw-repo/install_zk_sw_bullseye.sh | sudo bash

But I keep getting

ModuleNotFoundError: No module named ‘zymkey’

A bit confused/concerned as I bought 3 units of Zimkey, which isn’t that cheap, yet I can’t use a single one.

Please let me know what additional info you need to help me sort out this issue, thanks :slight_smile:

  1. Running the curl bash twice, or three times are “recommended” does not fix anything, and the logs are meaningless as everything is installed properly :
curl -G http://s3.amazonaws.com/zk-sw-repo/install_zk_sw_bullseye.sh | sudo bash
[sudo] password for An04Mal_B0Ss-Uz3R:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4055  100  4055    0     0   7768      0 --:--:-- --:--:-- --:--:--  7768

Sorry, try again.
[sudo] password for An04Mal_B0Ss-Uz3R:
Detected Bullseye. Will use Zymbit buster repo for now...
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Hit:4 https://packages.microsoft.com/debian/11/prod bullseye InRelease
Hit:5 https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye InRelease
Hit:6 https://deb.debian.org/debian-debug bullseye-debug InRelease
Hit:7 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:8 https://zk-sw-repo.s3.amazonaws.com/apt-repo-buster-aarch64 buster InRelease
Hit:9 https://deb.nodesource.com/node_14.x bullseye InRelease
Fetched 44.1 kB in 4s (12.4 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: inotify in /usr/local/lib/python3.9/dist-packages (0.2.10)
Requirement already satisfied: nose in /usr/local/lib/python3.9/dist-packages (from inotify) (1.3.7)
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pycurl in /usr/local/lib/python3.9/dist-packages (7.45.1)
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: progress in /usr/local/lib/python3.9/dist-packages (1.6)
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: python-gnupg in /usr/local/lib/python3.9/dist-packages (0.5.0)
done.
Importing Zymbit Packages gpg key... done.
Installing /etc/apt/sources.list.d/zymbit.list...done...Updating now.
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Hit:4 https://deb.nodesource.com/node_14.x bullseye InRelease
Hit:5 https://packages.microsoft.com/debian/11/prod bullseye InRelease
Hit:6 https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye InRelease
Hit:7 https://deb.debian.org/debian-debug bullseye-debug InRelease
Hit:8 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:9 https://zk-sw-repo.s3.amazonaws.com/apt-repo-buster-aarch64 buster InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Installing Zymkey Packages...

And running the little python script as in the guide gives:

python3 -c "import zymkey;
for ch in (0, 1):
    zymkey.client.set_perimeter_event_actions(ch, action_notify=False, action_self_destruct=False)
zymkey.client.clear_perimeter_detect_info()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'zymkey'

So I decided to install the zimkey module manually as follows: pip install zimkey

This shows some improvement, but then I am facing another error:


python3 -c “import zymkey;
for ch in (0, 1):
zymkey.client.set_perimeter_event_actions(ch, action_notify=False, action_self_destruct=False)
zymkey.client.clear_perimeter_detect_info()”
Traceback (most recent call last):
File “”, line 1, in
File “/home/An04Mal_B0Ss-Uz3R/.local/lib/python3.9/site-packages/zymkey/init.py”, line 3, in
from .module import Zymkey
File “/home/An04Mal_B0Ss-Uz3R/.local/lib/python3.9/site-packages/zymkey/module.py”, line 50, in
raise ZymkeyLibraryError(‘unable to find {}, checked {}’.format(os.path.basename(ZYMKEY_LIBRARY_PATH), prefixes))
zymkey.exceptions.ZymkeyLibraryError: unable to find libzk_app_utils.so, checked [‘/usr/lib/python3/dist-packages/usr/local/lib’, ‘/usr/local/lib’]


This time, it is `ZymkeyLibraryError: unable to find libzk_app_utils.so` but I haven't moved any single file anywhere!

Could you please assist?

@alohaJoe - I checked with a clean bullseye64 and the installation works for me. A couple of notes:

  • The only thing you need to run is the curl command. (no pip/pip3 commands)
  • There is no package named zimkey. I don’t think that could have done anything.
  • If you meant zymkey, that package is not relevent to the modern Zymkey software. You should uninstall it as it may have brought in really old code.
    pip uninstall zymkey
  • You seem to have python path problems somehow. You are looking in a local area rather than the systemwide python3.9. This most likely happened when you attempted to pip install zymkey. Running pip uninstall zymkey may fix that.

Can you check two things for me?

  1. Check to make sure libzk_app_utils.so is where it should be, in /usr/lib?
    ls -l /usr/lib/libzk_app_utils.so

  2. Check that Python package zku (the current name of our Python API package) is properly installed?
    pip3 show zku

Can you send me the output of the above two commands? If you are still having issues, I would recommend starting with a clean bullseye64 image and just run the curl script once with no additional installation steps and see if that works.

Bob

Hi @Bob_of_Zymbit

Thanks for your help! Indeed I installed zymkey, not zimkey (Typo… Sorry about that), which I uninstalled since then.

Rpi4B - Unit #1 and #2:

  1. libzk_app_utils.so is where it should be, in /usr/lib :
ls -l /usr/lib/libzk_app_utils.so
-rw-r--r-- 1 root root 59032 Dec 10  2021 /usr/lib/libzk_app_utils.so
  1. However zku is not found:
 pip3 show zku
WARNING: Package(s) not found: zku

Two different Rpi4B, two different installs, same problem…

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"

Rpi4B #1

uname -r
5.15.61-v8+

Rpi4B #2

uname -r
5.15.32-v8+

Hi @Bob_of_Zymbit ,

Some updates:

  • After starting with a clean bullseye64 image, Zymkey is working.
  • However, as soon as I start working in the encrypted partition / importing my project and restarted the Pi, Zymkey does not work anymore and blinks back fast!

Below the picture of where it hangs in the loading process:

I hope we can fix this soon.

It’s not really clear where you are in the process. Did you complete the encryption process (run curl -G https://s3.amazonaws.com/zk-sw-repo/mk_encr_sd_rfs.sh | sudo bash wait for the two automatic reboots and end up with an encrypted root partition)? The screen output looks like you did complete the encryption, and the /root partition was successfully unlocked by the Zymkey, And then after that something went wrong.

What did your code/application do? Did you install something that might have built a new initrd.img? Anything I can try and repeat?

We recommend that you get all of your code/applications how you want them in your image first, then go through the encryption process as the final step.

Bob

Hi @Bob_of_Zymbit

Seems like I almost got everything working but now, im facing a new issue: my Rpi4B has two users: a basic one and one with super user rights.

To encrypt the SD card, I’m using the one with super rights. The SD card is encrypted properly and the zymkey is slowly flashing blue, but as soon as i connected using SSH, I noticed that:

  • the basic user is gone !
  • the folder of the user with super user rights is now empty
  • /etc/passwd has been edited back to square one
  • same with sshd file. I configured it with a port different than 22, and it got back to 22 after encryption

Is that a known issue, or an expected behavior?

By the way, about “We recommend that you get all of your code/applications how you want them in your image first, then go through the encryption process as the final step.” I have a feeling that it should be the opposite since I’m losing all the data/application when I encrypt AFTER. And on the “how to” I’m reading this:

Prepare your application

If you intend to use your ZYMKEY4 to encrypt your root file system, you should complete that step now, using our guide. This step is highly recommended.

RESOURCES
Encrypt the root file system of your host device using LUKS and your ZYMKEY4.
Read article

You should then install your application on your host SBC (in the encrypted volume, if applicable).

Please note on the How To it says this:

One thing to note is that, if the external storage device has an ext4 formatted partition with the original root file system partition (e.g. /dev/mmcblk0p2) on it, this script will use what is already on the external storage device to convert the SD card. This cuts down time for converting lots of device root file systems and allows the script to be used in a mass production deployment.

This means if you are re-using the same USB stick from a previous encryption, it will reproduce your same root file system from that point in time. This is for customers who deploy hundreds of PI’s at a time.

Start with a fresh, re-formatted USB stick and you will get your last image.

I should add that until encryption completes, it will rapid flash. Once encryption completes it will return to the slow once every three seconds flash. You can use lsblk to see the encrypted root partition.

Hi @Bob_of_Zymbit

I finally got it all working, thanks a lot ! But now, facing issues with the RTC that I’m unable to get working.

Will open a new thread for that.