0

I am trying to deploy a Django app to Heroku which uses a client to connect to the api of an invoice service. Everything works when running localy, but when deploying on Heroku I get a Bad magic number errror:

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

Both my local environment and Heroku run on Python 3.6.4 so Python versions shouldn't be the problem. I have tried deleting pyc files, deploying with and without them but that doesn't change anything.

Any idea how I could fix it ?

syl-lo
  • 123
  • 1
  • 1
  • 5
  • 1
    You have .pyc files in your git repository somehow. You will need to remove them from there. – Daniel Roseman Mar 07 '18 at 20:24
  • I don't think there is any. They have always been in .gitignore and I have run 'find ./ -type f -name '*.pyc' -exec git rm {} \;' and similar commands multiple times. – syl-lo Mar 07 '18 at 20:33

0 Answers0