samedi 9 août 2014

Python 2.7 - erreur de serveur django 1.3 - Stack Overflow


I am using django version 1.3. Python manage.py runserver 0.0.0.0:8000 gives the following error.


Validating models...

Unhandled exception in thread started by < bound method Command.inner_run of < django.contrib.staticfiles.management.commands.runserver.Command object at 0x20eb110>>

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in inner_run
self.validate(display_num_errors=True)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name)

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)

File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)

File "/usr/local/lib/python2.7/dist-packages/tastypie/models.py", line 6, in <module>
from tastypie.utils import now

File "/usr/local/lib/python2.7/dist-packages/tastypie/utils/__init__.py", line 1, in <module>
from tastypie.utils.dict import dict_strip_unicode_keys

File "/usr/local/lib/python2.7/dist-packages/tastypie/utils/dict.py", line 1, in <module>
from django.utils.encoding import smart_bytes
ImportError: cannot import name smart_bytes



Its working fine with django 1.4.2+, I was using django1.4 then upgraded it


pip install django==1.4.5 --upgrade



Django 1.3 had the issues of smart_bytes, and from your traceback it shows the same error, its been resolved in Django 1.4, Try upgrading Django to the latest version of 1.5.




See https://github.com/django/django/blob/master/django/utils/encoding.py#L149


Also, always check the release notes before upgrading your Django.


Update:


Sorry about that, wow, what a brainfart ;).


I don't know the full history of that function, but looking at django.utils.encoding on Github.. tagged 1.3.7; this file does not contain the function that Tastypie is attempting to import. https://github.com/django/django/blob/1.3.7/django/utils/encoding.py


If you cannot upgrade Django, you'll need to patch your Tastypie.utils.dict file to work with what you have.



I am using django version 1.3. Python manage.py runserver 0.0.0.0:8000 gives the following error.


Validating models...

Unhandled exception in thread started by < bound method Command.inner_run of < django.contrib.staticfiles.management.commands.runserver.Command object at 0x20eb110>>

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in inner_run
self.validate(display_num_errors=True)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)

File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name)

File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)

File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)

File "/usr/local/lib/python2.7/dist-packages/tastypie/models.py", line 6, in <module>
from tastypie.utils import now

File "/usr/local/lib/python2.7/dist-packages/tastypie/utils/__init__.py", line 1, in <module>
from tastypie.utils.dict import dict_strip_unicode_keys

File "/usr/local/lib/python2.7/dist-packages/tastypie/utils/dict.py", line 1, in <module>
from django.utils.encoding import smart_bytes
ImportError: cannot import name smart_bytes


Its working fine with django 1.4.2+, I was using django1.4 then upgraded it


pip install django==1.4.5 --upgrade


Django 1.3 had the issues of smart_bytes, and from your traceback it shows the same error, its been resolved in Django 1.4, Try upgrading Django to the latest version of 1.5.



See https://github.com/django/django/blob/master/django/utils/encoding.py#L149


Also, always check the release notes before upgrading your Django.


Update:


Sorry about that, wow, what a brainfart ;).


I don't know the full history of that function, but looking at django.utils.encoding on Github.. tagged 1.3.7; this file does not contain the function that Tastypie is attempting to import. https://github.com/django/django/blob/1.3.7/django/utils/encoding.py


If you cannot upgrade Django, you'll need to patch your Tastypie.utils.dict file to work with what you have.


0 commentaires:

Enregistrer un commentaire