'Import "cryptography.fernet" could not be resolved'

I’m new to Python and trying to get this cryptography function running but I keep getting the message ‘Import “cryptography” could not be resolved’ (it points to line 1, column 6).

from cryptography import Fernet

masterPwd = input("What is the master password? >>")

def view():
    with open("passwordsUpdated.txt", "r") as f:
        for line in f.readlines():
            data = line.rstrip()
            user, passw = data.split("|")
            print("User: ", user, "Password: ", passw)

def add():
    name = input("Account name: ")
    pwd = input("Password: ")

    with open("passwordsUpdated.txt", "a") as f:
        f.write(name + "|" + pwd)


while True:
    mode = input("Add new password or view existing (view/add)? Q to quit. >>")
    if mode == "q":
        break

    if mode == "view":
        view()
    elif mode == "add":
        add()
    else:
        print("Invalid")
        continue

This is the video tutorial I am following: https://youtu.be/NpmFbWO6HPU?si=xzMSnkOjIyYpvhN7&t=4969 (it’s supposed to be a password manager)

I have already tried “pip install --upgrade pip” and “pip install --upgrade cffi” and have updated cryptography to the latest version. My python is version 3.14.0.

In a previous thread I was told that this is a problem with how my Python environment is configured.

Try replacing the first line with: from cryptography.fernet import Fernet

\\venvs>python -ic “from cryptography import Fernet”
Traceback (most recent call last):
File “”, line 1, in 
from cryptography import Fernet
ImportError: cannot import name ‘Fernet’ from ‘cryptography’

If that doesn’t work, double check you installed it into the same Python as you’re running the script in, and that cryptography was installed correctly from a wheel (it needs Rust to build from source, and pip falls back to building from source).

Thanks for the help! Installing rust helped with the problem.