4

I have a python module that tries to import from passlib.hash import pbkdf2_sha256, however when running the module, I get the ModuleNotFoundError.

I have tried running the module in my base environment, a venv, in a poetry shell, and I've tried reinstalling passlib through poetry install, pip install, pip install --force-reinstall, and none of it gets the module to see passlib being installed. I'm at a complete loss as to why this library just won't work.

The full error message is:

poetry run src/api-keychain/main.py --help

Traceback (most recent call last):
  File "XXX/src/api-keychain/main.py", line 5, in <module>
    from crypto import encrypt_key, decrypt_key
  File "XXX/src/api-keychain/crypto.py", line 5, in <module>
    from passlib.hash import pbkdf2_sha256
ModuleNotFoundError: No module named 'passlib'
Chris
  • 126
  • 1
  • 2
  • 9

1 Answers1

10

Since you mentioned about you successful installed passlib, I guess you might not install it with the python interpreter you are using.

First Try:

pip install passlib

If not work, it could because you have both Python2 and 3 try:

pip3 install passlib
python3 -m pip install passlib

And if you have an IDE like Pycharm, you can use it to check what packages are with the interpreter you are using via go to the Interpreter Settings.

Zichzheng
  • 1,090
  • 7
  • 25
  • Just adding a note, the ````pip install passlib```` command pipeline needs to be ran in the project directory of the virtual environment, right? – Ben Q Feb 20 '23 at 23:44