django ImportError:PyO3模块在每个解释器进程中只能初始化一次

rkkpypqq  于 2023-08-08  发布在  Go
关注(0)|答案(1)|浏览(202)

我正在做一个Django项目,其中包括DRF。应用程序已对接。
一切都工作正常,然后突然我得到了以下错误,在我的日志,我完全不知道它是如何到达

patients    | [uWSGI] getting INI configuration from /patients/src/_settings/local-test/uwsgi.ini
patients    | [uwsgi-static] added mapping for /static/ => /static/
patients    | *** Starting uWSGI 2.0.21 (64bit) on [Fri Jun  2 13:59:34 2023] ***
patients    | compiled with version: 10.2.1 20210110 on 02 June 2023 10:11:18
patients    | os: Linux-5.19.0-42-generic #43~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 21 16:51:08 UTC 2
patients    | nodename: 9be86066078d
patients    | machine: x86_64
patients    | clock source: unix
patients    | pcre jit disabled
patients    | detected number of CPU cores: 8
patients    | current working directory: /patients/src
patients    | detected binary path: /usr/local/bin/uwsgi
patients    | uWSGI running as root, you can use --uid/--gid/--chroot options
patients    | setgid() to 33
patients    | *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
patients    | chdir() to /patients/src
patients    | your memory page size is 4096 bytes
patients    | detected max file descriptor number: 1048576
patients    | building mime-types dictionary from file /etc/mime.types...1476 entry found
patients    | lock engine: pthread robust mutexes
patients    | thunder lock: disabled (you can enable it with --thunder-lock)
patients    | uwsgi socket 0 bound to TCP address :8080 fd 3
patients    | uWSGI running as root, you can use --uid/--gid/--chroot options
patients    | setgid() to 33
patients    | *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
patients    | Python version: 3.9.16 (main, May 23 2023, 14:17:54)  [GCC 10.2.1 20210110]
patients    | Python main interpreter initialized at 0x5640005ce9b0
patients    | uWSGI running as root, you can use --uid/--gid/--chroot options
patients    | setgid() to 33
patients    | *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
patients    | python threads support enabled
patients    | your server socket listen backlog is limited to 100 connections
patients    | your mercy for graceful operations on workers is 60 seconds
patients    | mapped 618762 bytes (604 KB) for 4 cores
patients    | *** Operational MODE: preforking+threaded ***
patients    | WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x5640005ce9b0 pid: 1 (default app)
patients    | mounting /patients/src/patients/wsgi.py on /patients
patients    | Traceback (most recent call last):
patients    |   File "/patients/src/patients/wsgi.py", line 16, in <module>
patients    |     application = get_wsgi_application()
patients    |   File "/usr/local/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
patients    |     django.setup(set_prefix=False)
patients    |   File "/usr/local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
patients    |     apps.populate(settings.INSTALLED_APPS)
patients    |   File "/usr/local/lib/python3.9/site-packages/django/apps/registry.py", line 114, in populate
patients    |     app_config.import_models()
patients    |   File "/usr/local/lib/python3.9/site-packages/django/apps/config.py", line 301, in import_models
patients    |     self.models_module = import_module(models_module_name)
patients    |   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
patients    |     return _bootstrap._gcd_import(name[level:], package, level)
patients    |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
patients    |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
patients    |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
patients    |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
patients    |   File "<frozen importlib._bootstrap_external>", line 850, in exec_module
patients    |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
patients    |   File "/patients/src/./patient/models.py", line 3, in <module>
patients    |     from django_cryptography.fields import encrypt
patients    |   File "/usr/local/lib/python3.9/site-packages/django_cryptography/fields.py", line 9, in <module>
patients    |     from django_cryptography.core.signing import SignatureExpired
patients    |   File "/usr/local/lib/python3.9/site-packages/django_cryptography/core/signing.py", line 10, in <module>
patients    |     from cryptography.exceptions import InvalidSignature
patients    |   File "/usr/local/lib/python3.9/site-packages/cryptography/exceptions.py", line 9, in <module>
patients    |     from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
patients    | ImportError: PyO3 modules may only be initialized once per interpreter process

字符串
我无法理解它是如何到达的。
我的docker-compose.yml看起来像

version: '3'
services:
    patients:
      container_name: patients
      image: patients:latest
      restart: always
      volumes:
        - ./:/patients/
      env_file: 
        - patients.env
      command: ["uwsgi", "--ini", "/patients/src/_settings/local-test/uwsgi.ini"]
      ports:
        - 8003:8080
      build: ./


这是我的uwsgi.ini

[uwsgi]
http-socket = :8080
chdir =/patients/src
master = 1
processes = 2
threads = 2
static-map = /static/=/static/
mount =/patients=/patients/src/patients/wsgi.py
manage-script-name = true
buffer-size = 65535
module=patients.wsgi
vacuum = True
gid = www-data
env = PYTHONDONTWRITEBYTECODE=1


从我有限的知识和经验,我认为这是由于一些在码头组成。
我得到这个错误突然当今天我做了容器向上的命令
第一个月

9bfwbjaz

9bfwbjaz1#

你升级了python包cryptography到新版本了吗?
降级到以前的主要版本:
pip install cryptography==40.0.2 --upgrade
这在我的情况下帮助。

相关问题