0

I have a small flask app, which runs fine in debug mode (vscode). When starting with uwsgi in a docker container, I get the following stack trace:

...
Traceback (most recent call last):
  File "main.py", line 14, in <module>
    from flask_jwt_extended import JWTManager
  File "/usr/local/lib/python3.9/site-packages/flask_jwt_extended/__init__.py", line 1, in <module>
    from .jwt_manager import JWTManager as JWTManager
  File "/usr/local/lib/python3.9/site-packages/flask_jwt_extended/jwt_manager.py", line 6, in <module>
    import jwt
  File "/usr/local/lib/python3.9/site-packages/jwt/__init__.py", line 1, in <module>
    from .api_jwk import PyJWK, PyJWKSet
  File "/usr/local/lib/python3.9/site-packages/jwt/api_jwk.py", line 7, in <module>
    from .algorithms import get_default_algorithms, has_crypto, requires_cryptography
  File "/usr/local/lib/python3.9/site-packages/jwt/algorithms.py", line 12, in <module>
    from .utils import (
  File "/usr/local/lib/python3.9/site-packages/jwt/utils.py", line 7, in <module>
    from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve
  File "/usr/local/lib64/python3.9/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py", line 11, in <module>
    from cryptography.hazmat._oid import ObjectIdentifier
  File "/usr/local/lib64/python3.9/site-packages/cryptography/hazmat/_oid.py", line 9, in <module>
    from cryptography.hazmat.bindings._rust import (
ImportError: PyO3 modules may only be initialized once per interpreter process

I don't use PyO3, the only module seems to be the flask_jwt_extended. The imports I make regarding this module are:

in main.py:

from flask_jwt_extended import JWTManager
jwt = JWTManager(app)

in api.py:

from flask_jwt_extended import create_access_token, get_jwt_identity, jwt_required

Really have no clue how to solve this.

Phipsen
  • 159
  • 3
  • 15
  • Issues lies in dependency package `cryptography`. See https://stackoverflow.com/a/76831227/9884812 – Ewro Aug 03 '23 at 19:52

0 Answers0