#๐Ÿ”’ No module named cryptography

33 messages ยท Page 1 of 1 (latest)

prime star
#

Ive tried running pip install cryptography, it was downloaded but im still getting this error

vestal hillBOT
#

@prime star

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

gritty burrow
#

you possibly have multiple python installed. instead of using the pip command directly to install, try using the python command with -m pip install cryptography instead

#

e.g. python -m pip install ...
or py -m pip install ...
depending on what "python" command you use to run the script.

#

that should ensure to use the specific pip of that python installation

fathom brook
#

What is this script?
If you wrote it yourself, you'd know what to install...
And if you downloaded it, please make sure it's safe.

26+ lines of imports is sus, importing cryptography can be sus or not - depending on context.

waxen merlin
#

Not necessarily 26 loc, right?

barren trellis
#

If cryptography can't be installed from a wheel, then it usually fails to install from source (i.e. at all), unless you happen to have Rust installed.

prime star
#

Still the same, no module named cryptography.

barren trellis
#

It may well have downloaded. Make sure it actually installed successfully (cryptography often doesn't) by posting the complete output from pip.

#

On unusual platforms, PyCryptodome is a more reliable bet, as it's all pure Python

prime star
barren trellis
#

Thanks.

prime star
#

im using cryptography.Fernet to import Fernet, which i use to encrypt data

barren trellis
#

Can you try the same again with python -m pip?

prime star
#

before running python -m pip i uninstalled it

barren trellis
#

Great. What about python -c "import cryptography"?

prime star
#

didnt display anything

barren trellis
#

Cool, that means there was no error, and the base module at least was imported successfully

prime star
#

Alright, let me test it.

barren trellis
#

How about `python -c "from cryptography.fernet import Fernet"

#

I need to go, but it crossed my mind that if you're running Windows on ARM, not on x86/amd64, then I couldn't find a Cryptography wheel for that architecture

#

Good luck!

prime star
#

Im still getting the same error

barren trellis
#

Drat. You're not in Python 3.14 are you?

If it was me, I'd go through the installation directories then, comparing what should be there with what actually is. Unfortunately this is best done locally (i.e., by you!).

gritty burrow
#

it should be

from cryptography.fernet import Fernet
                  ^
``` and not
```py
from cryptography.Fernet import Fernet
                  ^
#

(if cryptography was not installed, it would not include the ".Fernet" part in the error message)

#

@prime star

vestal hillBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.