Django/Celery can't find importlib - python

So I just updated django to 1.2.3 and now when I try to run 'python manage.py shell' to work in the django environment, I'm getting the following error.
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/opt/local/lib/python2.5/site-packages/django/core/management/commands/shell.py", line 18, in handle_noargs
loaded_models = get_models()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py", line 167, in get_models
self._populate()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/opt/local/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/opt/local/lib/python2.5/site-packages/django_celery-2.0.3-py2.5.egg/djcelery/models.py", line 7, in <module>
from celery import conf
File "/opt/local/lib/python2.5/site-packages/celery-2.0.3-py2.5.egg/celery/conf.py", line 6, in <module>
from celery import routes
File "/opt/local/lib/python2.5/site-packages/celery-2.0.3-py2.5.egg/celery/routes.py", line 2, in <module>
from celery.utils import instantiate, firstmethod, mpromise
File "/opt/local/lib/python2.5/site-packages/celery-2.0.3-py2.5.egg/celery/utils/__init__.py", line 9, in <module>
import importlib
ImportError: No module named importlib
Any ideas. I can't seem to find what's going on here and for all I can tell I'm running the same versions on my web server and I don't have the same error showing up.

importlib which was added in Python 2.7/3.1, I believe. You can download a port for pyton 2.5 here:
importlib 1.0.1 - Backport of importlib.import_module() from Python 2.7
Also check the setup.cfg for celery near the bottom and make sure all the other requirements are met (toward the bottom of the script).

importlib was added to Python in version 3.1, and then backported to Python 2.7. Third party backports are available on PyPI.
Also note that 'backported to 2.7' doesn't imply that all versions after 2.7 will have importlib. Python 3.0, I believe, does not have importlib.

Related

Why i am getting this error AttributeError: module 'collections' has no attribute 'Iterator while creating django project in django version 2.0.7?

Hi i am learning Django from this youtube video Python Django Web Framework - Full Course for Beginners from freecodecamp
when i tried to create a project using Django 2.0.7 in virtual environment. i am getting this error AttributeError: module 'collections' has no attribute 'Iterator dont know why please help me to fix this.
I am doing exactly what was shown in that tutorial like i created virualenvironment then i installed django 2.0.7 then i ran command django-admin startproject trydjango .
But i am getting this error.please tell me how to fix this
i tried with creating another virtual environment and even tried with othernames for project but i am keep on getting this error and i even tried to create it without . at end of the line
like
django-admin startproject trydjango
instead of
django-admin startproject trydjango .
Then it gives same error with a empty trydjango folder
(venv) C:\Users\chirag\Dev\trydjango>django-admin startproject trydjango .
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\chirag\Dev\trydjango\venv\Scripts\django-admin.exe\__main__.py", line 7, in <module>
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\core\management\__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\core\management\base.py", line 335, in execute
output = self.handle(*args, **options)
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\core\management\commands\startproject.py", line 20, in handle
super().handle('project', project_name, target, **options)
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\core\management\templates.py", line 117, in handle
django.setup()
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\__init__.py", line 16, in setup
from django.urls import set_script_prefix
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\urls\__init__.py", line 1, in <module>
from .base import (
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\urls\base.py", line 8, in <module>
from .exceptions import NoReverseMatch, Resolver404
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
from django.http import Http404
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\http\__init__.py", line 5, in <module>
from django.http.response import (
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\http\response.py", line 13, in <module>
from django.core.serializers.json import DjangoJSONEncoder
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
from django.core.serializers.base import SerializerDoesNotExist
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
from django.db import models
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
from django.db.models.aggregates import * # NOQA
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
from django.db.models.expressions import Case, Func, Star, When
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\db\models\expressions.py", line 486, in <module>
class TemporalSubtraction(CombinedExpression):
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\db\models\expressions.py", line 487, in TemporalSubtraction
output_field = fields.DurationField()
File "C:\Users\chirag\Dev\trydjango\venv\lib\site-packages\django\db\models\fields\__init__.py", line 155, in __init__
if isinstance(choices, collections.Iterator):
AttributeError: module 'collections' has no attribute 'Iterator'

How to fix the error that occurs when upgrading django 1.10 to 1.11?

After upgrading django from 1.10 to 1.11, I can't use the manage.py command. There are so many errors that I do not even know where to start and where to look for the cause of errors. I will be grateful for any help.
I paste all errors below.
File "SAGI-B/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/filer/models/__init__.py", line 3, in <module>
from .clipboardmodels import * # flake8: noqa
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/filer/models/clipboardmodels.py", line 9, in <module>
from . import filemodels
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/filer/models/filemodels.py", line 18, in <module>
from ..fields.multistorage_file import MultiStorageFileField
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/filer/fields/multistorage_file.py", line 12, in <module>
from easy_thumbnails import fields as easy_thumbnails_fields
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/easy_thumbnails/fields.py", line 2, in <module>
from easy_thumbnails import files
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/easy_thumbnails/files.py", line 14, in <module>
from easy_thumbnails import engine, exceptions, models, utils, signals, storage
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/easy_thumbnails/engine.py", line 12, in <module>
from easy_thumbnails import utils
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/easy_thumbnails/utils.py", line 15, in <module>
from easy_thumbnails.conf import settings
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/easy_thumbnails/conf.py", line 334, in <module>
settings = Settings()
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/easy_thumbnails/conf.py", line 21, in __init__
super(AppSettings, self).__init__(*args, **kwargs)
TypeError: __init__() takes exactly 2 arguments (1 given)
I have upgraded all dependencies with the command pip list --outdated --format = freeze | grep -v '^ \ - e' | cut -d = -f 1 | xargs -n1 pip install -U, which I found here: enter link description here
Now the number of errors has decreased to a few. I paste them below.
Traceback (most recent call last):
File "SAGI-B/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/marcin/.vens/sagi/local/lib/python2.7/site-packages/cmsplugin_filer_file/models.py", line 10, in <module>
from filer.utils.compatibility import python_2_unicode_compatible
ImportError: cannot import name python_2_unicode_compatible
Your pip install -U command has upgraded easy-thumbnails to 2.7.0, but that version dropped support for Django 1.11.X
Support for Django 1.11 was added in 2.5.0, so either 2.5.0 or 2.6.0 should work (depending on other requirements). You could install 2.6 with:
pip install --upgrade "easy-thumbnails<2.7.0"

Django - running manage.py produces fatal error for version.py: Not a git repository

I have copied my Django 1.4.3 app from one server to another. It is running using mod_wsgi daemon on the other server.
mod_python is installed, as verified by looking at php.info(). Python version is 2.7, and Apache version is 2.4.
I get the following error whenever I run manage.py runserver 0.0.0.0:8000:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 252, in fetch_command
app_name = get_commands()[subcommand]
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 128, in __init__
logging_config_module = importlib.import_module(logging_config_path)
File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/python2.7/site-packages/django/utils/log.py", line 6, in <module>
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 9, in <module>
from django.http import (HttpResponse, HttpResponseServerError,
File "/usr/lib/python2.7/site-packages/django/http/__init__.py", line 19, in <module>
from mod_python.util import parse_qsl
File "/usr/lib64/python2.7/site-packages/mod_python/__init__.py", line 25, in <module>
from . import version
File "/usr/lib64/python2.7/site-packages/mod_python/version.py", line 3
version = "fatal: Not a git repository (or any of the parent directories): .git
The version.py file has the following contents:
# THIS FILE IS AUTO-GENERATED BY setup.py
version = "fatal: Not a git repository (or any of the parent directories): .git
3.5.0-"
# Some build-time constants:
HTTPD = "/usr/sbin/httpd"
HTTPD_VERSION = "2.4.6"
APR_VERSION = "1.4.8"
LIBEXECDIR = "/usr/lib64/httpd/modules"
SYSCONFDIR = ""
TEST_MOD_PYTHON_SO = "/usr/local/src/mod_python-3.5.0/src/mod_python.so" #NB: This is for test.py only
TESTHOME = "/usr/local/src/mod_python-3.5.0/test"
PYTHON_BIN = "/bin/python"
The app requires python 2.7, and I don't know how to reset mod_python to something that's compatible with version 2.7.

Python unit-testing with nose + GAE plugin

Since today morning I'm having some weird problem with Python's unit-testing tool Nose + NoseGAE. I want to run unit-tests for my GAE project in terminal and it ends with this error:
Traceback (most recent call last):
File "/usr/local/bin/nosetests", line 8, in <module>
load_entry_point('nose==1.2.1', 'console_scripts', 'nosetests')()
File "/Library/Python/2.7/site-packages/nose-1.2.1-py2.7.egg/nose/core.py", line 118, in __init__
**extra_args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/Library/Python/2.7/site-packages/nose-1.2.1-py2.7.egg/nose/core.py", line 135, in parseArgs
self.config.configure(argv, doc=self.usage())
File "/Library/Python/2.7/site-packages/nose-1.2.1-py2.7.egg/nose/config.py", line 338, in configure
self.plugins.configure(options, self)
File "/Library/Python/2.7/site-packages/nose-1.2.1-py2.7.egg/nose/plugins/manager.py", line 284, in configure
cfg(options, config)
File "/Library/Python/2.7/site-packages/nose-1.2.1-py2.7.egg/nose/plugins/manager.py", line 99, in __call__
return self.call(*arg, **kw)
File "/Library/Python/2.7/site-packages/nose-1.2.1-py2.7.egg/nose/plugins/manager.py", line 167, in simple
result = meth(*arg, **kw)
File "build/bdist.macosx-10.7-intel/egg/nosegae.py", line 84, in configure
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver.py", line 61, in <module>
import simplejson
ImportError: No module named simplejson
It's weird because I'm not even using simplejson anywhere. I know it's part of Django, but I'm not using it either.
OS X 10.7.4
Python 2.7.1
Nose 1.2.1
NoseGAE 0.2.0
Do you have any idea what might be wrong?
This was probably just temporary problem in older GAE on OS X. Newer versions run without any problem.

Django 1.4.1 error loading MySQLdb module when attempting 'python manage.py shell'

I am trying to set up MySQL, and can't seem to be able to enter the Django manage.py shell interpreter. I did install MySQL-python but that did not solve the issue.
Getting the output below:
rrdhcp-10-32-44-126:django pavelfage$ python manage.py shell
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/shell.py", line 45, in handle_noargs
from django.db.models.loading import get_models
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 24, in load_backend
return import_module('.base', backend_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 16, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named _mysql
Any suggestions really appreciated.
You are probably missing the MySQLdb module. You basically just have to install it.
By the looks of it, you are using a Mac, so you might want to check out this answer for detailed installation instructions: How to install MySQLdb (Python data access library to MySQL) on Mac OS X?
On a totally alternate solution, as you mentionned Django development you might want to use sqlite3 instead of MySQL, which could be simpler to install.
You should be able to import MySQLdb from python shell.
Try importing MySQLdb from python shell not django
If you can not import MySQLdb from python shell;
It may caused because of 32-64 bit mismatch,
Try this link

Categories

Resources