pyca / bcrypt

Modern(-ish) password hashing for your software and your servers
Apache License 2.0
1.18k stars 159 forks source link

cannot import name '__author__' from 'bcrypt._bcrypt' #815

Closed zeilsell-user1 closed 1 month ago

zeilsell-user1 commented 1 month ago

Python 3.11.9

poetry show bcrypt name : bcrypt version : 4.1.3 description : Modern password hashing for your software and your servers

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/...internaladminserver/__main__.py", line 3, in <module>
    from internaladminserver.application.settings import settings
  File "/home/...internaladminserver/application/__init__.py", line 3, in <module>
    from .application import get_app
  File "/home/...internaladminserver/application/application.py", line 9, in <module>
    from headcoach_internaladminserver.application.lifetime import lifespan
  File "/home/...internaladminserver/application/lifetime.py", line 6, in <module>
    import bcrypt
  File "/home/.../.venv/lib/python3.11/site-packages/bcrypt/__init__.py", line 13, in <module>
    from ._bcrypt import (
ImportError: cannot import name '__author__' from 'bcrypt._bcrypt' (/home/.../.venv/lib/python3.11/site-packages/bcrypt/_bcrypt.cpython-311-x86_64-linux-gnu.so)

I have tried versions back to 4.1.0. The previous version, 4.0.1 fails because it doesn't support KDF

I have tried taking this to the minimal and it still fails

>$ poetry run python -c "import bcrypt; print(bcrypt.__file__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/...InternalAdminServer/.venv/lib/python3.11/site-packages/bcrypt/__init__.py", line 13, in <module>
    from ._bcrypt import (
ImportError: cannot import name '__author__' from 'bcrypt._bcrypt' (/home/...InternalAdminServer/.venv/lib/python3.11/site-packages/bcrypt/_bcrypt.cpython-311-x86_64-linux-gnu.so)
alex commented 1 month ago

This looks like your installation is somehow corrupted where you have two different versions of bcrypt installed. I suggest deleting your virtualenv and reinstalling.

zeilsell-user1 commented 1 month ago

Thanks @alex

I have blown away the venv and reinstalled completely and I am still getting the same error.

This is the bcrypt.dict

{'__name__': 'bcrypt._bcrypt', '__doc__': 'Internal module used by bcrypt.\n', '__package__': '', '__loader__': <_frozen_importlib_external.ExtensionFileLoader object at 0x7effbc59cdd0>, '__spec__': ModuleSpec(name='_bcrypt', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x7effbc59cdd0>, origin='/home/r...InternalAdminServer/./.venv/lib/python3.11/site-packages/bcrypt/_bcrypt.cpython-311-x86_64-linux-gnu.so'), 'hashpw': <built-in function hashpw>, 'encode_salt': <built-in function encode_salt>, '__version__': '0.4', '__file__': '/home/...InternalAdminServer/./.venv/lib/python3.11/site-packages/bcrypt/_bcrypt.cpython-311-x86_64-linux-gnu.so'}

I will create a completely fresh poetry project with just bcrypt and see if that has the same issue

zeilsell-user1 commented 1 month ago

Okay - @alex is right - a completely clean project with just bcrypt works (as expected). Closing this issue down and throwing my computer out the window.