django_pylibmc complains under Django 1.7 and python 3.4

柔情痞子 提交于 2019-12-12 03:14:13

问题


My environment: Django 1.7 Python 3.2

As a disclaimer, I'm new to Django and Python.

I'm going through this doc in order to use Memcachier with Django.

The installion process didn't give me any errors, but when I fire up my tests with ./manage.py tests I get the following error:

   return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, 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 1467, in exec_module
  File "<frozen importlib._bootstrap>", line 1572, in get_code
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File ".../lib/python3.4/site-packages/django_pylibmc/memcached.py", line 92
    except MemcachedError, e:

SyntaxError: invalid syntax

I'm looking at the python 3.x docs for errors and it seems that line 92 of that file is indeed not valid syntax, but I'm not sure.

Can anyone suggest a possible fix?


回答1:


That library does not appear to be compatible with Python 3.

However, as Amir suggests, there is no need to use it anyway; Django comes with a pylibmc backend, as described in the documentation.




回答2:


I know you are following the Heroku docs which suggest using django-pylibmc, but Django supports Pylibmc out of the box with django.core.cache.backends.memcached.PyLibMCCache. Since these are just python wrappers over the pylibmc C libraries there should be really no reason to go with django-pylibmc.

Also if you look at the README (https://github.com/jbalogh/django-pylibmc#requirements) for django-pylibmc it states that it was written and tested with Python 2.7, so the use of Python 3 is also problematic here.

I applaud your efforts for using Python 3 with Django, but please make sure that all your third party apps are compatible and I highly recommend reading this from the Django docs: https://docs.djangoproject.com/en/1.7/topics/python3/



来源:https://stackoverflow.com/questions/29189899/django-pylibmc-complains-under-django-1-7-and-python-3-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!