0

我正在尝试使用 python 3 将 Django 网站部署到 Amazon Web Services。现在,django-storages 与 python3 不兼容,所以我安装了兼容的 django-storages-redux。但是,当我试图:

python3 manage.py runserver

我得到这个:

Traceback (most recent call last):
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/jokes/views.py", line 6, in home_page
    response = render(request, 'home.html')
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/shortcuts.py", line 67, in render
    template_name, context, request=request, using=using)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/loader.py", line 99, in render_to_string
    return template.render(context, request)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/backends/django.py", line 74, in render
    return self.template.render(context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/base.py", line 209, in render
    return self._render(context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/base.py", line 201, in _render
    return self.nodelist.render(context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/base.py", line 903, in render
    bit = self.render_node(node, context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/debug.py", line 79, in render_node
    return node.render(context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/loader_tags.py", line 135, in render
    return compiled_parent._render(context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/base.py", line 201, in _render
    return self.nodelist.render(context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/base.py", line 903, in render
    bit = self.render_node(node, context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/template/debug.py", line 79, in render_node
    return node.render(context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/templatetags/static.py", line 105, in render
    url = self.url(context)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 16, in url
    return static(path)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 9, in static
    return staticfiles_storage.url(path)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/utils/functional.py", line 226, in inner
    self._setup()
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 394, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/core/files/storage.py", line 329, in get_storage_class
    return import_string(import_path or settings.DEFAULT_FILE_STORAGE)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1448, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/storages/backends/s3boto.py", line 24, in <module>
    from storages.utils import setting
ImportError: cannot import name 'setting'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
    response = self.get_response(request)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 218, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 261, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/views/debug.py", line 97, in technical_500_response
    html = reporter.get_traceback_html()
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/views/debug.py", line 383, in get_traceback_html
    c = Context(self.get_traceback_data(), use_l10n=False)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/views/debug.py", line 328, in get_traceback_data
    frames = self.get_traceback_frames()
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/views/debug.py", line 501, in get_traceback_frames
    'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame),
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/views/debug.py", line 234, in get_traceback_frame_variables
    cleansed[name] = self.cleanse_special_types(request, value)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/views/debug.py", line 189, in cleanse_special_types
    if isinstance(value, HttpRequest):
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/utils/functional.py", line 226, in inner
    self._setup()
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 394, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/core/files/storage.py", line 329, in get_storage_class
    return import_string(import_path or settings.DEFAULT_FILE_STORAGE)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1448, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/home/antoni4040/Documents/django-trunk/django/bin/thermostatis/env/lib/python3.4/site-packages/storages/backends/s3boto.py", line 24, in <module>
    from storages.utils import setting
ImportError: cannot import name 'setting'

奇怪,它试图导入的那个设置文件是什么?有没有人成功部署过这样的?

4

3 回答 3

1

我也遇到了这个问题。我能够通过启动一个新环境并重新安装包来解决。我相信我有两个包裹争夺“存储”名称。

这适用于 Python 3.4、Django 1.7.1 和 django-storages-redux 1.2.3。

于 2015-07-25T21:31:04.423 回答
0

你想冻结/你的脚本被冻结了吗?比如用 cx_Freeze。Cx_freeze 和据我所知其他冻结程序不能很好地处理 .egg 文件。您可能需要手动将第 3 方 api 的文件夹放在 /python34/Lib/site-packages 中。

于 2015-07-09T15:18:42.667 回答
0

我实际上以不同的方式解决了我的问题......我将它添加到我的 requirements.txt 文件中:

-e git+https://github.com/coagulant/django-storages-py3.git@73920742505b0c86b2fbc30274ff8b111e9b6f48#egg=django_storages-origin-py3

现在它开始工作了!使用不同的库,但仍然...

于 2015-07-09T15:52:53.303 回答