我正在尝试将一个Django应用程序部署到Heroku,它使用a client连接到发票服务的api。运行localy时一切正常,但在Heroku上部署时,我得到一个错误的幻数错误:
error at /bexiopy/auth/
Bad magic number
Request Method: GET
Request URL: https://oust-test.herokuapp.com/bexiopy/auth/
Django Version: 2.0.3
Exception Type: error
Exception Value:
Bad magic number
Exception Location: /app/.heroku/python/lib/python3.6/dbm/__init__.py in open, line 94
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.6.4
Python Path:
['/app',
'/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python36.zip',
'/app/.heroku/python/lib/python3.6',
'/app/.heroku/python/lib/python3.6/lib-dynload',
'/app/.heroku/python/lib/python3.6/site-packages',
'/app']
Server time: mer, 7 Mar 2018 19:53:24 +0000
Environment:
Request Method: GET
Request URL: https://oust-test.herokuapp.com/bexiopy/auth/
Django Version: 2.0.3
Python Version: 3.6.4
Installed Applications:
['jet.dashboard',
'jet',
'nested_admin',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'django_celery_beat',
'django_celery_results',
'bexiopy.apps.BexiopyConfig',
'database']
Installed Middleware:
('whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/views/generic/base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
89. return handler(request, *args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/bexiopy/views.py" in get
29. client = Client()
File "/app/.heroku/python/lib/python3.6/site-packages/bexiopy/api.py" in __init__
360. self.load_access_token_from_file()
File "/app/.heroku/python/lib/python3.6/site-packages/bexiopy/api.py" in load_access_token_from_file
611. access_token = shelve.open(token_file)
File "/app/.heroku/python/lib/python3.6/shelve.py" in open
243. return DbfilenameShelf(filename, flag, protocol, writeback)
File "/app/.heroku/python/lib/python3.6/shelve.py" in __init__
227. Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/app/.heroku/python/lib/python3.6/dbm/__init__.py" in open
94. return mod.open(file, flag, mode)
Exception Type: error at /bexiopy/auth/
Exception Value: Bad magic number
我的本地环境和Heroku都运行在Python 3.6.4上,因此Python版本不应该成为问题。我已经尝试删除pyc文件,使用和不使用它们进行部署,但这并没有改变任何内容。
我知道如何解决它?