# ImportError: No module named zymkey

**URL:** <https://community.zymbit.com/t/importerror-no-module-named-zymkey/554>\
**Category:** ZYMKEY4\
**Created:** [June 2, 2019, 1:35am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554 "2019-06-02T01:35:59Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![colporteur](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@colporteur](https://community.zymbit.com/u/colporteur)\
**Post date:** [June 2, 2019, 1:35am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/1 "2019-06-02T01:35:59Z")

</div>

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](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’]

---

<div class="post-metadata">

**Author:** ![colporteur](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@colporteur](https://community.zymbit.com/u/colporteur)\
**Post date:** [June 7, 2019, 8:15pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/2 "2019-06-07T20:15:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [June 7, 2019, 9:17pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/3 "2019-06-07T21:17:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![colporteur](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@colporteur](https://community.zymbit.com/u/colporteur)\
**Post date:** [June 9, 2019, 7:42pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/4 "2019-06-09T19:42:36Z")

</div>

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

Sean

---

<div class="post-metadata">

**Author:** ![colporteur](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@colporteur](https://community.zymbit.com/u/colporteur)\
**Post date:** [June 13, 2019, 11:42pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/5 "2019-06-13T23:42:20Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![vidya](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vidya](https://community.zymbit.com/u/vidya)\
**Post date:** [January 20, 2020, 9:41am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/6 "2020-01-20T09:41:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![imanolgo](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@imanolgo](https://community.zymbit.com/u/imanolgo)\
**Post date:** [February 3, 2021, 11:55am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/7 "2021-02-03T11:55:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [February 3, 2021, 3:54pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/8 "2021-02-03T15:54:40Z")

</div>

@imanolgo - It sounds like your installation was not completed successfully. Details for installation are here: [Getting Started](https://community.zymbit.com/t/getting-started-zymkey4i-with-raspberry-pi/202).

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

---

<div class="post-metadata">

**Author:** ![imanolgo](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@imanolgo](https://community.zymbit.com/u/imanolgo)\
**Post date:** [February 3, 2021, 4:24pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/9 "2021-02-03T16:24:22Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [February 3, 2021, 6:47pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/10 "2021-02-03T18:47:29Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![imanolgo](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@imanolgo](https://community.zymbit.com/u/imanolgo)\
**Post date:** [February 4, 2021, 8:29am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/11 "2021-02-04T08:29:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alohaJoe](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@alohaJoe](https://community.zymbit.com/u/alohaJoe)\
**Post date:** [September 11, 2022, 8:57am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/12 "2022-09-11T08:57:52Z")

</div>

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 🙂

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 :

```auto
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:

```auto
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:

```auto

```

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’]

```auto

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?
```

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [September 12, 2022, 6:37pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/13 "2022-09-12T18:37:13Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![alohaJoe](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@alohaJoe](https://community.zymbit.com/u/alohaJoe)\
**Post date:** [September 13, 2022, 1:34am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/14 "2022-09-13T01:34:07Z")

</div>

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` :

```auto
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:

```auto
 pip3 show zku
WARNING: Package(s) not found: zku

```

Two different Rpi4B, two different installs, same problem…

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

```

Rpi4B #1

```auto
uname -r
5.15.61-v8+

```

Rpi4B #2

```auto
uname -r
5.15.32-v8+

```

---

<div class="post-metadata">

**Author:** ![alohaJoe](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@alohaJoe](https://community.zymbit.com/u/alohaJoe)\
**Post date:** [September 13, 2022, 3:27am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/15 "2022-09-13T03:27:40Z")

</div>

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:

 ![Capture.PNG](https://canada1.discourse-cdn.com/flex027/uploads/zymbit/original/2X/7/70175c5f71508539ad200e3c79cea1a48c75572f.jpeg)

I hope we can fix this soon.

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [September 13, 2022, 4:05am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/17 "2022-09-13T04:05:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alohaJoe](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@alohaJoe](https://community.zymbit.com/u/alohaJoe)\
**Post date:** [September 13, 2022, 12:10pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/20 "2022-09-13T12:10:30Z")

</div>

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 ](https://docs.zymbit.com/tutorials/encrypt-rfs/zymkey4/)
> 
> You should then install your application on your host SBC (in the encrypted volume, if applicable).

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [September 13, 2022, 4:22pm UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/21 "2022-09-13T16:22:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alohaJoe](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@alohaJoe](https://community.zymbit.com/u/alohaJoe)\
**Post date:** [October 29, 2022, 7:26am UTC](https://community.zymbit.com/t/importerror-no-module-named-zymkey/554/22 "2022-10-29T07:26:32Z")

</div>

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.
