I have the following on my MacBook with Osx Lion:
Mysql running with xampp (http://www.apachefriends.org/it/xampp.html)
Django 1.3 running in a virtualenv
I installed Mysql-python with pip install MySQL-python
but when trying to use manage.py syncdb I get the following error:
(django_1.3)Daniel-Mac:fz_biblio daniel$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/core/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/core/management/commands/syncdb.py", line 7, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/core/management/sql.py", line 6, in <module>
from django.db import models
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/db/__init__.py", line 78, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/db/utils.py", line 33, in load_backend
return import_module('.base', backend_name)
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/daniel/.python-eggs/MySQL_python-1.2.3-py2.5-macosx-10.7-i386.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/daniel/.python-eggs/MySQL_python-1.2.3-py2.5-macosx-10.7-i386.egg-tmp/_mysql.so: mach-o, but wrong architecture
(django_1.3)Daniel-Mac:fz_biblio daniel$ mate "/Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/db/backends/mysql/base.py
> "
(django_1.3)Daniel-Mac:fz_biblio daniel$ mate /Users/daniel/Sites/django-proj/virtual-env/django_1.3/lib/python2.5/site-packages/django/db/backends/mysql/base.py
Any idea in order to make django work with mysql in my environment?!?!
I finally sorted out the problem installing the right version of MySQL for my machine.
I installed MySQL 64bit version --> Mac OS X ver. 10.6 (x86, 64-bit)
After installing it Everything started working fine. I guess it was due to the fact that my previous installation was a 32bit one, that why mysql-python was complaining for the wrong architecture.
Related
I tried various ways (every solution mentioned in the stackoverflow) to solve the problem but still the problems continues.
When I run : "python manage.py migrate" the following error is shown
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/base.py", line 305, in run_from_argv
self.execute(*args, **cmd_options)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/base.py", line 353, in execute
self.check()
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/base.py", line 385, in check
include_deployment_checks=include_deployment_checks,
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 61, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/checks/database.py", line 9, in check_database_backends
for conn in connections.all():
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/db/utils.py", line 226, in all
return [self[alias] for alias in self]
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 28, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
Then I tried: "pip install mysql-python" as per the suggestions in the stackoverflow similar questions. I got the following error
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/7_/cx21vvvn5cqdypfndc7j_jl80000gn/T/pip-build-JjMQeR/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/7_/cx21vvvn5cqdypfndc7j_jl80000gn/T/pip-build-JjMQeR/mysql-python/
I even tried: "brew install mysql-connector-c" but the same error starts to come.
I finally did it:
First I installed the command line developer tools required by running the following code inside the virtualenv
$ xcode-select --install
Then I installed MySQL-python by using the following code
pip install MySQL-python
Finally I migrated the database using:
python manage.py migrate
It worked without any errors
The main problem with the error was that I didn't installed the command line developer tools required.
After installing OS X Mavericks, I have been having issues running django's server:
(rango_tutorial)christohersmbp2:tango_with_django_project christopherspears$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/core/management/base.py", line 280, in execute
translation.activate('en-us')
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 130, in activate
return _trans.activate(language)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 188, in activate
_active.value = translation(language)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 6, in <module>
from django.contrib.admin.sites import AdminSite, site
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 4, in <module>
from django.contrib.admin.forms import AdminAuthenticationForm
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/contrib/admin/forms.py", line 6, in <module>
from django.contrib.auth.forms import AuthenticationForm
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 17, in <module>
from django.contrib.auth.models import User
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/contrib/auth/models.py", line 48, in <module>
class Permission(models.Model):
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/db/models/base.py", line 96, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/db/models/base.py", line 264, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/db/models/options.py", line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/db/utils.py", line 198, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/db/utils.py", line 113, in load_backend
return import_module('%s.base' % backend_name)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 35, in <module>
raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): dlopen(/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/lib-dynload/_sqlite3.so, 2): Symbol not found: _sqlite3_enable_load_extension
Referenced from: /Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/lib-dynload/_sqlite3.so
Expected in: /usr/lib/libsqlite3.dylib
in /Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/lib-dynload/_sqlite3.so
I think the issue is that the sqlite3 module has gone missing for some reason:
(rango_tutorial)christohersmbp2:tango_with_django_project christopherspears$ python
Python 2.7.5 (default, Dec 31 2013, 11:46:08)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: dlopen(/Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/lib-dynload/_sqlite3.so, 2): Symbol not found: _sqlite3_enable_load_extension
Referenced from: /Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/lib-dynload/_sqlite3.so
Expected in: /usr/lib/libsqlite3.dylib
in /Users/christopherspears/.virtualenvs/rango_tutorial/lib/python2.7/lib-dynload/_sqlite3.so
I'm not sure what is causing this. Isn't the sqlite3 module normally just part of Python?
Updating OS X is notorious for messing up all sorts of Developer Tools.
What is your output when you type which sqlite3? How about other developer tools like which gcc? If they are missing you may need to reinstall Xcode. I know many users had to reinstall XCode after updating to Mavericks.
Here's the link for more information: https://developer.apple.com/xcode/
Uninstalling and reinstalling python with brew seemed to help with the earlier problem. Of course now, python is broken in that virtual environment:
(rango_tutorial)christohersmbp2:tango_with_django_project christopherspears$ python manage.py runserver
dyld: Library not loaded: #executable_path/../.Python
Referenced from: /Users/christopherspears/.virtualenvs/rango_tutorial/bin/python
Reason: image not found
Trace/BPT trap: 5
(rango_tutorial)christohersmbp2:tango_with_django_project christopherspears$ python
dyld: Library not loaded: #executable_path/../.Python
Referenced from: /Users/christopherspears/.virtualenvs/rango_tutorial/bin/python
Reason: image not found
Trace/BPT trap: 5
Very new to coding. I've been trying to install this tablestacker: http://datadesk.github.io/latimes-table-stacker/
And I'm running into problems with manage.py syncdb, and I can't get past this particular error. My hunch is: I have both Python 2.6 and 2.7 on my computer, and I'm not sure how to make sure everything's running with 2.7. I have a feeling things are being installed for 2.6.
Any advice is much appreciated! Thanks in advance.
Here is my error:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/core/management/__init__.py", line 459, in execute_manager
utility.execute()
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.6-py2.7.egg/south/management/commands/__init__.py", line 10, in <module>
import django.template.loaders.app_directories
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/template/loaders/app_directories.py", line 23, in <module>
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
django.core.exceptions.ImproperlyConfigured: ImportError bakery: No module named bakery
Thanks, I did import south, used python manage.py migrate, and created aliases for all python2.7 commands like pip and easy_install so to be sure I'm not using 2.6.
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
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.