some problems of using Python's Cryptography on Windows

Question:

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/cryptographie.py", line 1, in <module>
    from cryptography.fernet import Fernet
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsite-packagescryptographyfernet.py", line 16, in <module>
    from cryptography.hazmat.primitives.hmac import HMAC
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsite-packagescryptographyhazmatprimitiveshmac.py", line 10, in <module>
    from cryptography.hazmat.backends.openssl.hmac import _HMACContext
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsite-packagescryptographyhazmatbackendsopenssl__init__.py", line 6, in <module>
    from cryptography.hazmat.backends.openssl.backend import backend
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsite-packagescryptographyhazmatbackendsopensslbackend.py", line 13, in <module>
    from cryptography import utils, x509
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsite-packagescryptographyx509__init__.py", line 7, in <module>
    from cryptography.x509.base import (
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsite-packagescryptographyx509base.py", line 28, in <module>
    from cryptography.x509.extensions import (
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsite-packagescryptographyx509extensions.py", line 25, in <module>
    from cryptography.x509.general_name import (
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsite-packagescryptographyx509general_name.py", line 9, in <module>
    from email.utils import parseaddr
  File "C:Users/edoua/Documentsemail.py", line 18, in <module>
    server.login(email_address, email_password)
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsmtplib.py", line 739, in login
    (code, resp) = self.auth(
  File "C:UsersedouaAppDataLocalProgramsPythonPython310libsmtplib.py", line 641, in auth
    response = encode_base64(initial_response.encode('ascii'), eol='')
NameError: name 'encode_base64' is not defined

`

It is coming from the smtplib.py 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.

Asked By: ed.vcnt

||

Answers:

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

Answered By: Brian