1
votes

the django-storages docs recommend using boto3 for managing static file storage with S3. expected this config to work but it's err'ing out

requirements.txt

boto3==1.4.6
botocore==1.6.3
django-storages==1.1.4

prod.py [settings]

from .common import *
from storages.backends.s3boto import S3BotoStorage

...

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
AWS_ACCESS_KEY_ID = ENV_STR('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = ENV_STR('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = ENV_STR('AWS_STORAGE_BUCKET_NAME')
S3_URL = 'http://s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = S3_URL
MEDIA_URL = 'http://s3.amazonaws.com/%s/media/' % 
AWS_STORAGE_BUCKET_NAME
ADMIN_MEDIA_PREFIX = STATIC_URL + '/admin/'
AWS_S3_ENCRYPTION = True
AWS_IS_GZIPPED = True

but runing tests on manage.py collectstatic --noinput fail with a syntax err from storages package in storages/backends/s3boto.py:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
execute_from_command_line(sys.argv)
  File "/home/ubuntu/virtualenvs/venv-3.5.3/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
  File "/home/ubuntu/virtualenvs/venv-3.5.3/lib/python3.5/site-packages/django/core/management/__init__.py", line 302, in execute
settings.INSTALLED_APPS
  File "/home/ubuntu/virtualenvs/venv-3.5.3/lib/python3.5/site-packages/django/conf/__init__.py", line 55, in __getattr__
self._setup(name)
  File "/home/ubuntu/virtualenvs/venv-3.5.3/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
  File "/home/ubuntu/virtualenvs/venv-3.5.3/lib/python3.5/site-packages/django/conf/__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/opt/circleci/python/3.5.3/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/ubuntu/brightest-list/project/settings/prod.py", line 7, in <module>
from storages.backends.s3boto import S3BotoStorage
 File "/home/ubuntu/virtualenvs/venv-3.5.3/lib/python3.5/site-packages/storages/backends/s3boto.py", line 139
except S3ResponseError, e:
                      ^
 SyntaxError: invalid syntax

running python 3. my initial hypothesis is it's a dependency version conflict, but I've tried uninstalling and reinstalling boto3 and storages to no effect. appreciate any guidance or suggestions, otherwise I may uninstall boto3 and revert back to boto.

1

1 Answers

2
votes

django-storages==1.1.4 does not support python3. This release is of 2012 so I would not recommend using such old version. This issue provides some more information about it. Try using a new version like 1.5 or newer. You can also review the code and you will see that it is compatible with python3.x.