python - Django fails to find psycopg2 module -


i installing python 3.5, django 1.10 , psycopg2 2.7.1 on amazon ec2 server in order use postgresql database. using python 3 inside virtual environment, , followed classic installation steps:

cd /home/mycode virtualenv-3.5 p3env source p3env/bin/activate pip install django cd kenbot django-admin startproject kenbot pip install psycopg2 

then have edited settings.py file in project define database settings:

databases = { 'default': {     'engine': 'django.db.backends.postgresql_psycopg2',     'name': 'deleted',     'user': 'deleted',     'password': 'deleted',     'host': 'deleted',     'port': '5432', }    

finally type (while still in virtual environment):

python manage.py makemigrations 

and following errors:

traceback (most recent call last):   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/db/backends/postgresql/base.py", line 20, in <module>     import psycopg2 database importerror: no module named 'psycopg2'  during handling of above exception, exception occurred:  traceback (most recent call last):   file "manage.py", line 22, in <module>     execute_from_command_line(sys.argv)   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 367, in execute_from_command_line     utility.execute()   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 341, in execute     django.setup()   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/__init__.py", line 27, in setup     apps.populate(settings.installed_apps)   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/apps/registry.py", line 108, in populate     app_config.import_models(all_models)   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/apps/config.py", line 199, in import_models     self.models_module = import_module(models_module_name)   file "/home/mycode/p3env/lib64/python3.5/importlib/__init__.py", line 126, in import_module     return _bootstrap._gcd_import(name[level:], package, level)   file "<frozen importlib._bootstrap>", line 986, in _gcd_import   file "<frozen importlib._bootstrap>", line 969, in _find_and_load   file "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked   file "<frozen importlib._bootstrap>", line 673, in _load_unlocked   file "<frozen importlib._bootstrap_external>", line 662, in exec_module   file "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/contrib/auth/models.py", line 4, in <module>     django.contrib.auth.base_user import abstractbaseuser, baseusermanager   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/contrib/auth/base_user.py", line 52, in <module>     class abstractbaseuser(models.model):   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/db/models/base.py", line 119, in __new__     new_class.add_to_class('_meta', options(meta, app_label))   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/db/models/base.py", line 316, in add_to_class     value.contribute_to_class(cls, name)   file "/home/mycode/p3env/local/lib/python3.5/dist-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 "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/db/__init__.py", line 33, in __getattr__     return getattr(connections[default_db_alias], item)   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/db/utils.py", line 211, in __getitem__     backend = load_backend(db['engine'])   file "/home/mycode/p3env/local/lib/python3.5/dist-packages/django/db/utils.py", line 115, in load_backend     return import_module('%s.base' % backend_name)   file "/home/mycode/p3env/lib64/python3.5/importlib/__init__.py", line 126, in import_module     return _bootstrap._gcd_import(name[level:], package, level)   file "/home/mycode/p3env/local/lib/python3.5/dist-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' 

i have not found issue anywhere on stackoverflow. 1 point may relevant, when browse directory of virtual environment, notice django installed in /home/mycode/p3env/lib/python3.5/dist-packages whereas psysopg2 in /home/mycode/p3env/lib64/python3.5/dist-packages.

thanks help!

as suggested @dentemm: issue resolved copying psysopg2 directories current location in lib64 directory, directory django installed /home/mycode/p3env/lib/python3.5/dist-packages.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -