Confusion about usage
See original GitHub issueI am using Python 3.7.6 on Windows 10 64-bit (1909). I get the problem with Nuitka 0.6.8 (not tried earlier versions) :
>python -m nuitka --version
0.6.8
Python: 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)]
Executable: C:\Program Files\Python37\python.exe
OS: Windows
Arch: x86_64
Nuitka was installed with PIP. No VEnv used. Python was installed with “python-3.7.6-amd64.exe”.
The paramiko module was installed by PIP as a dependency of pysftp. I suspect the PyNaCl module was installed as a dependency of paramiko.
This is the code (nuitkaTest.py) to reproduce the problem:
import paramiko
#import nacl
#import nacl._sodium
print("OK")
Although it also happens with programs that import “pysftp”, since that depends on paramiko.
This is how I compiled the code:
python -m nuitka --recurse-all --remove-output --show-progress --show-modules --show-scons nuitkaTest.py
And when I run the resulting executable, this is what it outputs:
>nuitkaTest.exe
Traceback (most recent call last):
File "......\nuitkaTest.py", line 1, in <module>
import paramiko
File "C:\Program Files\Python37\lib\site-packages\paramiko\__init__.py", line 22, in <module paramiko>
from paramiko.transport import SecurityOptions, Transport
File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 90, in <module paramiko.transport>
from paramiko.ed25519key import Ed25519Key
File "C:\Program Files\Python37\lib\site-packages\paramiko\ed25519key.py", line 22, in <module paramiko.ed25519key>
import nacl.signing
File "C:\Program Files\Python37\lib\site-packages\nacl\signing.py", line 17, in <module nacl.signing>
import nacl.bindings
File "C:\Program Files\Python37\lib\site-packages\nacl\bindings\__init__.py", line 17, in <module nacl.bindings>
from nacl.bindings.crypto_aead import (
File "C:\Program Files\Python37\lib\site-packages\nacl\bindings\crypto_aead.py", line 18, in <module nacl.bindings.crypto_aead>
from nacl._sodium import ffi, lib
ModuleNotFoundError: No module named 'nacl._sodium'
I tried tricking Nuitka to import the module (see the commented-out import lines), without success. I also tried using command line parameters (–include-package & --recurse-to) without success.
And I was also able to reproduce the same problem using this code, which has a much smaller dependency list:
import nacl.signing
#import nacl
#import nacl._sodium
print("OK")
But for some reason the problem does not happen if you ONLY import “nacl”.
For what it’s worth, I believe the paramiko & nacl modules are correctly installed:
>python
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
>>> import nacl
>>> import nacl.signing
>>>
And my programs work fine with the Python interpreter.
I have the latest version of paramiko installed (2.7.1 according to pip list).
I also have the latest version of PyNaCl installed (1.3.0 according to pip list).
Any work-around to this apparent bug would be great…
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Thanks, I’ve done more experimenting, and using --standalone does allow it to work… At the expense of needing a ton of “.pyd” files in a “nuitkaTest.dist” folder (which is useless for me as I need a self-contained executable). I hadn’t realised it was putting the executable inside that folder, and so I had been inadvertently testing an older executable.
So it seems the problem is a Nuitka limitation - it’s unable to create an executable that doesn’t need some or all of the following files present:
nacl/_sodium.pyd pyexpat.pyd select.pyd unicodedata.pyd _asyncio.pyd _bz2.pyd _cffi_backend.pyd _ctypes.pyd _decimal.pyd _elementtree.pyd _hashlib.pyd _lzma.pyd _msi.pyd _multiprocessing.pyd _overlapped.pyd _queue.pyd _socket.pyd _sqlite3.pyd _ssl.pyd _tkinter.pyd
This is a great shame, and I hope the issue can be rectified eventually.
The trap of accelerated binary and standalone binary being in a different directory is very real. Not sure though, if Nuitka should feel entitled to remove both. But an error would probably do good.
For #575 there is #230 but no progress. So being on a roadmap is not quite right. But maybe some day, there is not just simply somebody who wants it, but also somebody who creates it. For all I can tell, that person is not me until a company pays me good daily rate to do it.