PyInstaller - ModuleNotFoundError: No module named 'rsa'

49 views Asked by At

I am trying to package a complex program using PyInstaller and, no matter what I try, I always get the following error:

ModuleNotFoundError: No module named 'rsa'

Trying to sort the problem out, I have written a minimal program which still has the same problem:

import rsa

if __name__ == '__main__':
    print('Key generation')
    public_key, private_key = rsa.newkeys(1024)
    print(public_key)
    print(private_key)
    with open("public.pem", "wb") as f:
        f.write(public_key.save_pkcs1("PEM"))
    with open("private.pem", "wb") as f:
        f.write(private_key.save_pkcs1("PEM"))

To package the program I have used both:

pyinstaller main.py

and

pyinstaller --hidden-import rsa main.py

Anytime I run the program,I get:


Traceback (most recent call last):
  File "main.py", line 1, in <module>
ModuleNotFoundError: No module named 'rsa'
[39533] Failed to execute script 'main' due to unhandled exception!

This is the library I am using:

rsa

Any suggestions?

0

There are 0 answers