some problems of using Python's Cryptography on Windows

I would like to use the cryptography’s module on Windows, I am using version 1.12 and Python 3.10.6, and I have some problems. Actually, when I run my script, I receive the error :


Traceback (most recent call last):
  File "C:/Users/edoua/Documents/", line 1, in <module>
    from cryptography.fernet import Fernet
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\", line 16, in <module>
    from cryptography.hazmat.primitives.hmac import HMAC
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\hazmat\primitives\", line 10, in <module>
    from cryptography.hazmat.backends.openssl.hmac import _HMACContext
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\hazmat\backends\openssl\", line 6, in <module>
    from cryptography.hazmat.backends.openssl.backend import backend
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\hazmat\backends\openssl\", line 13, in <module>
    from cryptography import utils, x509
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\", line 7, in <module>
    from cryptography.x509.base import (
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\", line 28, in <module>
    from cryptography.x509.extensions import (
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\", line 25, in <module>
    from cryptography.x509.general_name import (
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptography\x509\", line 9, in <module>
    from email.utils import parseaddr
  File "C:\Users/edoua/Documents\", line 18, in <module>
    server.login(email_address, email_password)
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\", line 739, in login
    (code, resp) = self.auth(
  File "C:\Users\edoua\AppData\Local\Programs\Python\Python310\lib\", line 641, in auth
    response = encode_base64(initial_response.encode('ascii'), eol='')
NameError: name 'encode_base64' is not defined


It is coming from the file. Also, I precise that the module works perfectly, I can use all the functions of the module base64. So the problem is coming from the word ‘encode_base64’. Please help !

I tried to launch my program, and that error occures, I expected that it was going to work.

>Solution :

You have a local module C:\Users/edoua/Documents\ that is shadowing the email module from the Python standard library. Rename to something else, or move it to somewhere that isn’t on the Python path.

Leave a Reply