我的目标是用python3.10在CentOs 7上托管Django应用程序
我已经设法下载和配置Python,sqlite与manage.py运行服务器一起工作,但当我试图用apache托管它时,它不工作。
Apache抛出错误:ImportError: /usr/local/lib/python3.10/lib-dynload/_sqlite3.cpython-310-x86_64-linux-gnu.so: undefined symbol: sqlite3_trace_v2
已安装的版本
- 系统:CentOs 7
- Python语言:3.10.4
- 平方:3.28.0
- 修改wsgi:4.9.0
- Apache服务器:2.4.6
Apache .配置文件
WSGIScriptAlias / /var/www/portal/portal/wsgi.py
WSGIPythonPath /var/www/portal/:/var/www/venv/lib/python3.10/site-packages
<VirtualHost *:80>
ServerName 192.168.1.25
Alias /static /var/www/portal/static/
DocumentRoot /var/www/portal
<Directory /opt/portal/static>
AllowOverride All
Require all granted
Allow from all
</Directory>
<Directory /var/www/portal/portal>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
完整追溯:
Traceback (most recent call last):
File "/var/www/portal/portal/wsgi.py", line 22, in <module>
application = get_wsgi_application()
File "/var/www/venv/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/var/www/venv/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/var/www/venv/lib/python3.10/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/var/www/venv/lib/python3.10/site-packages/django/apps/config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/var/www/venv/lib/python3.10/site-packages/django/contrib/auth/models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/var/www/venv/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "/var/www/venv/lib/python3.10/site-packages/django/db/models/base.py", line 141, in __new__
new_class.add_to_class("_meta", Options(meta, app_label))
File "/var/www/venv/lib/python3.10/site-packages/django/db/models/base.py", line 369, in add_to_class
value.contribute_to_class(cls, name)
File "/var/www/venv/lib/python3.10/site-packages/django/db/models/options.py", line 235, in contribute_to_class
self.db_table, connection.ops.max_name_length()
File "/var/www/venv/lib/python3.10/site-packages/django/utils/connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "/var/www/venv/lib/python3.10/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/var/www/venv/lib/python3.10/site-packages/django/db/utils.py", line 208, in create_connection
backend = load_backend(db["ENGINE"])
File "/var/www/venv/lib/python3.10/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/var/www/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 15, in <module>
from sqlite3 import dbapi2 as Database
File "/usr/local/lib/python3.10/sqlite3/__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.10/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: /usr/local/lib/python3.10/lib-dynload/_sqlite3.cpython-310-x86_64-linux-gnu.so: undefined symbol: sqlite3_trace_v2
1条答案
按热度按时间jvlzgdj91#
我没有找到任何解决这个问题的方法,但是我已经把python降级到3.9.12,现在它可以工作了。