Fedora 30 - ModuleNotFoundError: No module named 'nacl'

Asked by Danie de Jager on 2019-05-29

I installed dkimpy using

pip3 install dkimpy

on fedora 30. The generation of RSA keys succeeds. It fails when trying to create for ed25519 though. pep8 is installed as well (1.7.1). nacl is installed.

Traceback (most recent call last):
  File "/usr/local/bin/dknewkey", line 11, in <module>
    load_entry_point('dkimpy==0.9.2', 'console_scripts', 'dknewkey')()
  File "/usr/local/lib/python3.7/site-packages/dkim/dknewkey.py", line 116, in main
    priv_key = GenEd25519Keys(private_key_file)
  File "/usr/local/lib/python3.7/site-packages/dkim/dknewkey.py", line 58, in GenEd25519Keys
    import nacl.signing # Yes, pep-8, but let's not make everyone install nacl
ModuleNotFoundError: No module named 'nacl'

Requirement already satisfied: pep8 in /usr/local/lib/python3.7/site-packages (1.7.1)


Question information

English Edit question
dkimpy Edit question
No assignee Edit question
Solved by:
Stuart Gathman
Last query:
Last reply:
Danie de Jager (danie.dejager) said : #2

Hi, I have that installed too but still getting the error:

# dnf install python3-libnacl.noarch
Last metadata expiration check: 0:05:36 ago on Mon 10 Jun 2019 08:33:33 SAST.
Package python3-libnacl-1.6.1-6.fc30.noarch is already installed.

# pip3 install libnacl
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Requirement already satisfied: libnacl in /usr/lib/python3.7/site-packages (1.6.1)

Scott Kitterman (kitterman) said : #3

It's PyNaCl, not libnacl.

# pip3 install PyNaCl
Collecting PyNaCl
  Downloading https://files.pythonhosted.org/packages/27/15/2cd0a203f318c2240b42cd9dd13c931ddd61067809fee3479f44f086103e/PyNaCl-1.3.0-cp34-abi3-manylinux1_x86_64.whl (759kB)
    100% |████████████████████████████████| 768kB 1.4MB/s
Requirement already satisfied: cffi>=1.4.1 in /usr/lib/python3/dist-packages (from PyNaCl) (1.12.2)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from PyNaCl) (1.12.0)
Installing collected packages: PyNaCl
Successfully installed PyNaCl-1.3.0

# ls /usr/local/lib/python3.7/dist-packages/
PyNaCl-1.3.0.dist-info/ nacl/
# ls /usr/local/lib/python3.7/dist-packages/nacl/
__init__.py __pycache__ _sodium.abi3.so bindings encoding.py exceptions.py hash.py hashlib.py public.py pwhash secret.py signing.py utils.py
root@l5580:/home# python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nacl

Also, the Fedora package is python3-pynacl. (And python2-pynacl) It is a version 1.3.0 - same as you get from pip.

Danie de Jager (danie.dejager) said : #5

Thanks Stuart Gathman, that solved my question.

Offtopic but relevant: python3-libnacl is a different python wrapper for libnacl. It is not interchangeable with pynacl, but an alternate wrapping. I prefer libsodium a maintained and CPU optimized fork of libnacl - and in fact, python3-pynacl and python3-libnacl actually wrap libsodium, not libnacl.