samedi 29 novembre 2014

python - Django - de 2,7 ImportError : impossible d'importer le nom - Stack Overflow


I am having problem with 1 error, I installed all apps on Django 1.6.2 and Django 1.5.5 and having the same problem.


My settings are:


Django 1.5.5


INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'polib',
'easymode',
'localeurl',
'rosetta',
'efc',
)

Django 1.6.2


INSTALLED_APPS += (
"polib",
"easymode",
"localeurl",
"rosetta",
"efc",
)

And here is the error:


Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/base.py", line 284, in execute
self.validate()
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/base.py", line 310, in validate
num_errors = get_validation_errors(s, app)
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/validation.py", line 34, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/efc/webapps/efc/lib/python2.7/django/db/models/loading.py", line 196, in get_app_errors
self._populate()
File "/home/efc/webapps/efc/lib/python2.7/django/db/models/loading.py", line 78, in _populate
self.load_app(app_name)
File "/home/efc/webapps/efc/lib/python2.7/django/db/models/loading.py", line 99, in load_app
models = import_module('%s.models' % app_name)
File "/home/efc/webapps/efc/lib/python2.7/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/home/efc/webapps/efc/myproject/efc/models.py", line 4, in <module>
from easymode.i18n.decorators import I18n
File "/home/efc/lib/python2.7/easymode/i18n/__init__.py", line 22, in <module>
import easymode.i18n.gettext
File "/home/efc/lib/python2.7/easymode/i18n/gettext.py", line 24, in <module>
from easymode.utils import polibext
File "/home/efc/lib/python2.7/easymode/utils/polibext.py", line 11, in <module>
from rosetta import polib
ImportError: cannot import name polib

The last line in the 'polibext.py' line 11 is:


if 'rosetta' in settings.INSTALLED_APPS:
from rosetta import polib
else:
try:
import polib
except ImportError:
raise ImproperlyConfigured(
"""
Please install either django-rosetta:
http://code.google.com/p/django-rosetta/
or polib:
http://bitbucket.org/izi/polib/src/
otherwise easymode.utils.polibext won't work"""
)

I installed both. Still having the error.


Can you please help?


Thanks




UPDATE:


As rentgeeen has found out, the problem was with django-rosetta 0.7.4 version. See his comment below.




Looks like you don't have django-rosetta installed. Run


pip install django-rosetta

from the console. That should install django-rosetta and it's dependedcies (six, requests and polib).


In the remote chance that you have django-rosetta installed, but not polib, run


pip install polib

As a sidenote, you might wanna look into virtualenv tutorials (for Webfaction or otherwise: http://michal.karzynski.pl/blog/2013/09/14/django-in-virtualenv-on-webfactions-apache-with-mod-wsgi/) If you plan on having several python projects on your account, I'd strongly advise it.



I am having problem with 1 error, I installed all apps on Django 1.6.2 and Django 1.5.5 and having the same problem.


My settings are:


Django 1.5.5


INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'polib',
'easymode',
'localeurl',
'rosetta',
'efc',
)

Django 1.6.2


INSTALLED_APPS += (
"polib",
"easymode",
"localeurl",
"rosetta",
"efc",
)

And here is the error:


Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/base.py", line 284, in execute
self.validate()
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/base.py", line 310, in validate
num_errors = get_validation_errors(s, app)
File "/home/efc/webapps/efc/lib/python2.7/django/core/management/validation.py", line 34, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/efc/webapps/efc/lib/python2.7/django/db/models/loading.py", line 196, in get_app_errors
self._populate()
File "/home/efc/webapps/efc/lib/python2.7/django/db/models/loading.py", line 78, in _populate
self.load_app(app_name)
File "/home/efc/webapps/efc/lib/python2.7/django/db/models/loading.py", line 99, in load_app
models = import_module('%s.models' % app_name)
File "/home/efc/webapps/efc/lib/python2.7/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/home/efc/webapps/efc/myproject/efc/models.py", line 4, in <module>
from easymode.i18n.decorators import I18n
File "/home/efc/lib/python2.7/easymode/i18n/__init__.py", line 22, in <module>
import easymode.i18n.gettext
File "/home/efc/lib/python2.7/easymode/i18n/gettext.py", line 24, in <module>
from easymode.utils import polibext
File "/home/efc/lib/python2.7/easymode/utils/polibext.py", line 11, in <module>
from rosetta import polib
ImportError: cannot import name polib

The last line in the 'polibext.py' line 11 is:


if 'rosetta' in settings.INSTALLED_APPS:
from rosetta import polib
else:
try:
import polib
except ImportError:
raise ImproperlyConfigured(
"""
Please install either django-rosetta:
http://code.google.com/p/django-rosetta/
or polib:
http://bitbucket.org/izi/polib/src/
otherwise easymode.utils.polibext won't work"""
)

I installed both. Still having the error.


Can you please help?


Thanks



UPDATE:


As rentgeeen has found out, the problem was with django-rosetta 0.7.4 version. See his comment below.




Looks like you don't have django-rosetta installed. Run


pip install django-rosetta

from the console. That should install django-rosetta and it's dependedcies (six, requests and polib).


In the remote chance that you have django-rosetta installed, but not polib, run


pip install polib

As a sidenote, you might wanna look into virtualenv tutorials (for Webfaction or otherwise: http://michal.karzynski.pl/blog/2013/09/14/django-in-virtualenv-on-webfactions-apache-with-mod-wsgi/) If you plan on having several python projects on your account, I'd strongly advise it.


Related Posts:

0 commentaires:

Enregistrer un commentaire