0
我完全失去了能力,無法爲我的問題找到解決方案。我開始使用virtualenv並在python版本2.7
中安裝了最新版本的django。然後我跟着django教程,而不是在開發服務器上工作,我使用apache2 localhost,一切工作正常。然後檢查MySQL的支持,我改變了設置文件,並安裝mysqlclient
和使用python manage.py makemigrations
其次python manage.py migrate
並沒有出錯。最後我重新啓動apache,出現500 Internal Server Error
。我現在提供apache錯誤日誌和我的設置文件。Django中的MySQLdb錯誤
[Thu Feb 04 11:24:13.190280 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] Traceback (most recent call last):
[Thu Feb 04 11:24:13.190504 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunner/wsgi.py", line 16, in <module>
[Thu Feb 04 11:24:13.190516 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] application = get_wsgi_application()
[Thu Feb 04 11:24:13.190711 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu Feb 04 11:24:13.190724 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] django.setup()
[Thu Feb 04 11:24:13.190925 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Thu Feb 04 11:24:13.190938 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] apps.populate(settings.INSTALLED_APPS)
[Thu Feb 04 11:24:13.191272 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
[Thu Feb 04 11:24:13.191288 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] app_config.import_models(all_models)
[Thu Feb 04 11:24:13.191620 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
[Thu Feb 04 11:24:13.191641 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] self.models_module = import_module(models_module_name)
[Thu Feb 04 11:24:13.191934 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
[Thu Feb 04 11:24:13.191949 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Feb 04 11:24:13.192004 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
[Thu Feb 04 11:24:13.192043 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
[Thu Feb 04 11:24:13.192083 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
[Thu Feb 04 11:24:13.192123 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
[Thu Feb 04 11:24:13.192162 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 1129, in _exec
[Thu Feb 04 11:24:13.192201 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 1471, in exec_module
[Thu Feb 04 11:24:13.192241 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
[Thu Feb 04 11:24:13.192456 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/runner/models.py", line 4, in <module>
[Thu Feb 04 11:24:13.192469 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] class Question(models.Model):
[Thu Feb 04 11:24:13.193404 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/db/models/base.py", line 108, in __new__
[Thu Feb 04 11:24:13.193436 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] new_class.add_to_class('_meta', Options(meta, app_label))
[Thu Feb 04 11:24:13.193520 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/db/models/base.py", line 299, in add_to_class
[Thu Feb 04 11:24:13.193532 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] value.contribute_to_class(cls, name)
[Thu Feb 04 11:24:13.194132 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/db/models/options.py", line 263, in contribute_to_class
[Thu Feb 04 11:24:13.194165 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Thu Feb 04 11:24:13.194409 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
[Thu Feb 04 11:24:13.194424 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Thu Feb 04 11:24:13.194730 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/db/utils.py", line 212, in __getitem__
[Thu Feb 04 11:24:13.194745 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] backend = load_backend(db['ENGINE'])
[Thu Feb 04 11:24:13.194807 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/db/utils.py", line 116, in load_backend
[Thu Feb 04 11:24:13.194818 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] return import_module('%s.base' % backend_name)
[Thu Feb 04 11:24:13.194876 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
[Thu Feb 04 11:24:13.194887 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Feb 04 11:24:13.194927 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
[Thu Feb 04 11:24:13.194966 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
[Thu Feb 04 11:24:13.195005 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
[Thu Feb 04 11:24:13.195045 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
[Thu Feb 04 11:24:13.195084 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 1129, in _exec
[Thu Feb 04 11:24:13.195123 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 1471, in exec_module
[Thu Feb 04 11:24:13.195163 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
[Thu Feb 04 11:24:13.195234 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] File "/home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 28, in <module>
[Thu Feb 04 11:24:13.195245 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
[Thu Feb 04 11:24:13.195297 2016] [:error] [pid 23833] [remote 127.0.0.1:25140] django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: /home/kapil/work/database/roadrunner/roadrunnerground/lib/python2.7/site-packages/_mysql.so: undefined symbol: _Py_ZeroStruct
這是關於數據庫配置的settings.py內容。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'roadrunner',
'USER': 'root',
'PASSWORD': 'kapilgarg',
'HOST': 'localhost',
}
}
Apache的錯誤日誌的最後一行,它指出_mysql.so : undefined symbol
,似乎有一些問題,鏈接或某些版本不匹配的問題。有人可以請請幫助我?它將不勝感激。
請出示你的Apache配置。您正在使用哪種操作系統,以及您安裝了哪些軟件包?你說你使用Python 2.7,但是回溯提到了Python 3.4。 – Alasdair