Python Django Mysql Expected in: flat namespace - python

I'm working on a project by using Python(2.7) and Django(1.10) in which I need to use mysql as database, I have installed XAMPP on Mac OSX and created a database.
Here's my requirements.txt:
asn1crypto==0.24.0
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
cryptography==2.3
Django==1.10.4
enum34==1.1.6
idna==2.6
ipaddress==1.0.22
MySQL-python==1.2.5
mysqlclient==1.3.6
ndg-httpsclient==0.5.1
passlib==1.7.1
Pillow==5.1.0
pusher==2.0.1
pyasn1==0.4.4
pycparser==2.18
pyOpenSSL==18.0.0
requests==2.18.4
securetrading==1.0.14
six==1.11.0
stripe==1.82.1
urllib3==1.22
When I run my Django application by using this command as:
python manage.py runserver
It through an error like below:
Unhandled exception in thread started by Traceback (most recent call last): File
"/Users/abdul/multiEnv/lib/python2.7/site-packages/django/utils/autoreload.py",
line 226, in wrapper
fn(*args, **kwargs) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/core/management/commands/runserver.py",
line 113, in inner_run
autoreload.raise_last_exception() File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/utils/autoreload.py",
line 249, in raise_last_exception
six.reraise(*_exception) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/utils/autoreload.py",
line 226, in wrapper
fn(*args, **kwargs) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/init.py",
line 27, in setup
apps.populate(settings.INSTALLED_APPS) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/apps/registry.py",
line 108, in populate
app_config.import_models(all_models) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/apps/config.py",
line 199, in import_models
self.models_module = import_module(models_module_name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py",
line 37, in import_module
import(name) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/contrib/auth/models.py",
line 4, in
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File
"/Users/abdul/multiEnv/lib/python2.7/site-packages/django/contrib/auth/base_user.py",
line 52, in
class AbstractBaseUser(models.Model): File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/db/models/base.py",
line 119, in new
new_class.add_to_class('_meta', Options(meta, app_label)) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/db/models/base.py",
line 316, in add_to_class
value.contribute_to_class(cls, name) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/db/models/options.py",
line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File
"/Users/abdul/multiEnv/lib/python2.7/site-packages/django/db/init.py",
line 33, in getattr
return getattr(connections[DEFAULT_DB_ALIAS], item) File "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/db/utils.py",
line 211, in getitem
backend = load_backend(db['ENGINE']) File "/Users/abdul/multiEnv/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 "/Users/abdul/multiEnv/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
line 28, in
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module:
dlopen(/Users/abdul/multiEnv/lib/python2.7/site-packages/_mysql.so,
2): Symbol not found: _mysql_affected_rows Referenced from:
/Users/abdul/multiEnv/lib/python2.7/site-packages/_mysql.so
Expected in: flat namespace in
/Users/abdul/multiEnv/lib/python2.7/site-packages/_mysql.so

Related

I am using Mobile Security Framework. When run python manage.py runserver, it displays this kind of error

Unhandled exception in thread started by <function wrapper at 0x062BE630>
Traceback (most recent call last):
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\contrib\auth\models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\contrib\auth\base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\models\base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Mobile-Security-Framework-MobSF-master\Python27\lib\site-packages\django\db\utils.py", line 134, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'sqlite3'
Error was: No module named postgresql.base
Pretty self explanatory.
See:No module named postgresql.base
Install postgresql, and configure it properly or use the default sqlite3 backend.

I can not run a server on Django

I have a problem: after the python manage.py runserver command I receive the following error which I can not solve:
Unhandled exception in thread started by <function wrapper at 0xb6712e64>
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/usr/lib/python2.7/dist-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/usr/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib/python2.7/dist-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/redactor/admin.py", line 3, in <module>
from redactor.widgets import JQueryEditor
ImportError: cannot import name JQueryEditor
How can I solve this problem? Many where we recommend that you sudo easy_install pip the team, but it did not help.
Are you sure that the name of the widget class is correct?
I was checking django-redactor and django-redactoreditor and they don't have a class named "JQueryEditor".

Django manage.py runserver got AppRegistryNotReady: Models aren't loaded yet

I hit a problem when run django from command line with manage.py runserver.
The same code is fine with Django 1.5 several months ago.
Today I wanna pickup the code again and run upon Django 1.8.3 and python2.7.10 .
Now, got error here:
Traceback (most recent call last):
File "manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 198, 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 "/media/wni/study/workspace4320151111/weichun/mytheme/models.py", line 8, in <module>
from mezzanine.pages.models import Page
File "/media/wni/study/workspace4320151111/weichun/mezzanine/pages/models.py", line 34, in <module>
class Page(BasePage):
File "/media/wni/study/workspace4320151111/weichun/mezzanine/core/models.py", line 350, in __new__
return super(OrderableBase, cls).__new__(cls, name, bases, attrs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 298, in __new__
new_class.add_to_class(field.name, copy.deepcopy(field))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "/media/wni/study/workspace4320151111/weichun/mezzanine/generic/fields.py", line 226, in contribute_to_class
super(KeywordsField, self).contribute_to_class(cls, name)
File "/media/wni/study/workspace4320151111/weichun/mezzanine/generic/fields.py", line 84, in contribute_to_class
cls._meta.get_fields_with_model()]:
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 56, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 432, in get_fields_with_model
return [self._map_model(f) for f in self.get_fields()]
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 740, in get_fields
return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 802, in _get_fields
all_fields = self._relation_tree
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 709, in _relation_tree
return self._populate_directed_relation_graph()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 681, in _populate_directed_relation_graph
all_models = self.apps.get_models(include_auto_created=True)
File "/usr/local/lib/python2.7/dist-packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 168, in get_models
self.check_models_ready()
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
Anyone knows how to fix it?
Thanks.
Wesley
I think you need to change your wsgi.py file as you go for different version of Django.
import os
import sys
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'YourAppName.settings'
application = WSGIHandler()
And try to comment all third party application imported in settings.py.
1] ./manage.py runserver will use your wsgi.py however it looks like the stack trace you've shown at the top does not include the wsgi file. Therefore the error is occurring before the wsgi file is loaded.
2] This could well be an issue with your Django settings. For example,may in LOGGING a filename in a non-existent directory.
3] or check this

Get errors trying to do python manage.py runserver

Catch errors trying to do manage.py runserver. GEOS has already installed. Database is created (I use PostgreSQL), all packages from requirements is successfully installed. When I run python manage.py runserver I get this messages.
(virualenv) C:\Users\Alexander\Desktop\myproject>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\core\management\__init__.py", line 312, in execute
django.setup()
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models(all_models)
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\apps\config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "C:\Python27\Lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\contrib\auth\models.py", line 41, in <module>
class Permission(models.Model):
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\db\models\base.py", line 139, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\db\models\base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\db\models\options.py", line 250, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\db\__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\db\utils.py", line 240, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\db\utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Python27\Lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 8, in <module>
from .features import DatabaseFeatures
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
from django.contrib.gis.db.models import aggregates
File "C:\Users\Alexander\Desktop\myproject\virualenv\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 12, in <module>
"See also https://docs.djangoproject.com/en/%s/ref/contrib/gis/install/geolibs/" % get_docs_version())
django.core.exceptions.ImproperlyConfigured: GEOS is required and has not been detected. Are you sure it is installed? See also https://docs.djangoproject.com/en/1.8/ref/contrib/gis/install/geolibs/
Any ideas how to solve it?
UPD: result of pip freeze:
(virualenv) C:\Users\Alexander\Desktop\myproject>pip freeze
amqp==1.4.9
anyjson==0.3.3
beautifulsoup4==4.1.3
billiard==3.3.0.23
bleach==1.4.1
boto==2.0
celery==3.1.23
chardet==2.3.0
Django==1.8.2
django-ajax-selects==1.3.6
django-appconf==1.0.2
django-celery==3.1.17
django-celery-email==1.1.4
django-contrib-comments==1.6.1
django-datatable-view==0.8.3
django-debug-toolbar==1.3.0
django-extensions==1.5.5
django-filter==0.10.0
django-formtools==1.0
django-grappelli==2.6.5
django-haystack==2.4.0
django-liststyle==0.2a0
django-multiselectfield==0.1.3
django-nocaptcha-recaptcha==0.0.18
django-postman==3.2.2
django-registration-redux==1.2
django-schedule==0.5b0
django-static-jquery==2.1.4
django-tagging==0.4
djangorestframework==3.1.2
docopt==0.4.0
ecdsa==0.13
elasticsearch==1.7.0
Fabric==1.10.1
filebrowser-safe==0.3.8
future==0.9.0
geopy==1.10.0
grappelli-safe==0.3.13
html5lib==0.99999
ipython==3.1.0
jsonfield==1.0.3
kombu==3.0.35
mailchimp==2.0.9
Mezzanine==4.1.0
mutagen==1.29
oauthlib==0.7.2
opbeat==3.0.2
paramiko==1.15.2
Pillow==2.8.1
psycopg2==2.6
pyactiveresource==2.1.1
pycrypto==2.6.1
pygeocoder==1.1.4
pysolr==3.3.2
python-dateutil==2.4.2
python-ptrace==0.8.1
pytz==2015.4
PyYAML==3.11
requests==2.7.0
requests-oauthlib==0.5.0
ShopifyAPI==2.1.3
six==1.9.0
sqlparse==0.1.15
tzlocal==1.0
urllib3==1.16
vobject==0.6.6
Werkzeug==0.10.4

Django/PostgreSQL - ImproperlyConfigured Error

I started a Django project using PostgreSQL and it was working fine after setup, I could add things to the database, view it in admin etc. Being new to Postgres, I thought it would be a good idea to quit the terminal to see if if it would 'auto connect' to the database upon restarting (like SQLite does). However now it throws this error:
Kyle$ python manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x10f6e4c08>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/django/contrib/auth/models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Library/Python/2.7/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 108, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 299, in add_to_class
value.contribute_to_class(cls, name)
File "/Library/Python/2.7/site-packages/django/db/models/options.py", line 263, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 212, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 116, 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 "/Library/Python/2.7/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2
Unhandled exception in thread started by <function wrapper at 0x10b03bc08>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/django/contrib/auth/models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Library/Python/2.7/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 108, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 299, in add_to_class
value.contribute_to_class(cls, name)
File "/Library/Python/2.7/site-packages/django/db/models/options.py", line 263, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 212, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 116, 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 "/Library/Python/2.7/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2
When importing the psycopg2 there is no error and inside the psql shell if I type \c it says I have connected to server 'Kyle' (my server name as specified in my django settings) as User 'Kyle' (also as specified in settings).
NB: Using all the latest releases for everything
I think this is a dependency issue, because I realised I wasn't in my virtual environment (it works when I'm in it).

Categories