Im trying to start a django project from scratch but i have an error that says "ImportError: No Module Named 'pysqlite2'"
I'm using Python 3.6.0. I will write steps which im following
Creating project
> django-admin startproject testproject
Trying to start an app
> python manage.py startapp demo
Immediately after enters that command, it returns me a long text which includes error's path etc.
Traceback (most recent call last):
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 34, in <module>
from pysqlite2 import dbapi2 as Database
ModuleNotFoundError: No module named 'pysqlite2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 36, in <module>
from sqlite3 import dbapi2 as Database
File "/usr/local/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/home/berkin/pythonenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/contrib/auth/models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/db/models/base.py", line 119, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/db/models/base.py", line 316, in add_to_class
value.contribute_to_class(cls, name)
File "/home/berkin/pythonenv/local/lib/python3.6/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 "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/home/berkin/pythonenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/berkin/pythonenv/local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 39, 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): No module named '_sqlite3'
What i tried?
- I installed sqlite3-dev with using sudo apt get ...
- I tried to install pip install pysqlite2
- I tried to alter source.py which is inside the virtual env folder but it wasnt worked.
But i figured out that when im not using virtual env, i mean without entering source /bin/activate, "python manage.py startapp demo" command has worked. When i activate env, it returns an error which i mentioned above.
according to this answer https://stackoverflow.com/a/23414147/2174832
There is no public version of pysqlite for Python 3.x. For Python 3.x,
the sqlite3 module in the standard library is the most up-to date
version of pysqlite there is.
run the command pip install sqlite3 within your activated virtualenv and use this module instead of pysqlite2. To activate your virtualenv go to /folderofvirtualenv/bin
and run the command source activate
Related
I am use django to build the project, when I run python manage.py makemigrations it get the error message:
Traceback (most recent call last):
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
import psycopg2 as Database
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/psycopg2/__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/psycopg2/_psycopg.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_PQbackendPID'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/mingzhe/Desktop/webapp/electric/electric/manage.py", line 22, in <module>
main()
File "/Users/mingzhe/Desktop/webapp/electric/electric/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/apps/config.py", line 269, in import_models
self.models_module = import_module(models_module_name)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/contrib/auth/models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/db/models/base.py", line 141, in __new__
new_class.add_to_class("_meta", Options(meta, app_label))
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/db/models/base.py", line 369, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/db/models/options.py", line 231, in contribute_to_class
self.db_table, connection.ops.max_name_length()
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/utils/connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/db/utils.py", line 193, in create_connection
backend = load_backend(db["ENGINE"])
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/django/db/backends/postgresql/base.py", line 28, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/mingzhe/Desktop/webapp/electric/env/lib/python3.10/site-packages/psycopg2/_psycopg.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_PQbackendPID'
I already create virtualenv here is my step:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew update
$ brew install postgresql
$ brew services start postgresql
$ virtualenv env
$ source env/bin/activate
(env) $ pip install django psycopg2-binary
I has been used most people's solution: install psycopg2-binary not psycopg2 but still get symbol not found in flat namespace '_PQbackendPID'
My system environment:
macOS Monterey
Python3.10.7 64bit
asgiref==3.5.2
Django==4.1.1
psycopg2-binary==2.9.3
sqlparse==0.4.2
I has try to brew uninstall postgresql and install again it still have same issue, I'm afraid I'm doing something wrong or maybe I don't get how it work on Macbook M1.
Any help or explanation is welcome! Thank you.
try this
pip3 install psycopg2-binary --no-cache-dir
pip uninstall psycopg2
pip install psycopg2-binary --no-cache-dir
I installed the recent version of MySQL for my mac (macOS 12(ARM, 64-bit), DMG Archive) and created a database called storefront. I'm working in a pipenv virtual environment and install mysqlclient. I've also updated my DATABASES settings to point to my new database in my settings.py file.
DB Settings. But whenever I try to run the server I get an error. NameError: name '_mysql' is not defined Also at the top, (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e') I thought by installing the ARM version I wouldn't deal with this error. I wonder if it's pointing to the wrong file within my env despite adding the PATH to my .zshrc info. Is there a special way to point to the correct mysql or am I setting things up incorrectly? Here's my error message "
Traceback (most recent call last):
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/MySQLdb/__init__.py", line 18, in <module>
from . import _mysql
ImportError: dlopen(/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/MySQLdb/_mysql.cpython-39-darwin.so, 0x0002): tried: '/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/MySQLdb/_mysql.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/a0c08w6/Documents/Scripts/Django/storefront/manage.py", line 22, in <module>
main()
File "/Users/a0c08w6/Documents/Scripts/Django/storefront/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/apps/config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "/opt/homebrew/Cellar/python#3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/contrib/auth/models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/db/models/base.py", line 141, in __new__
new_class.add_to_class("_meta", Options(meta, app_label))
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/db/models/base.py", line 369, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/db/models/options.py", line 235, in contribute_to_class
self.db_table, connection.ops.max_name_length()
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/utils/connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/db/utils.py", line 208, in create_connection
backend = load_backend(db["ENGINE"])
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/opt/homebrew/Cellar/python#3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
import MySQLdb as Database
File "/Users/a0c08w6/.local/share/virtualenvs/storefront-A2x2yZd3/lib/python3.9/site-packages/MySQLdb/__init__.py", line 24, in <module>
version_info, _mysql.version_info, _mysql.__file__
NameError: name '_mysql' is not defined
Error tell you, you have mysql macOs build for x86_64, but you should set up build for 'arm64e'.
here you can find both version for macOs:
https://dev.mysql.com/downloads/mysql/
I install mySql many times on macos... and now i have mariaDb
https://mariadb.com/kb/en/installing-mariadb-on-macos-using-homebrew/
For me it was easier to install
I'm running a django app with mariadb. It used to work just fine, however I have left this project idle for a while and now I'm just coming back to it and I can't figure out why it's now breaking.
I get the following error when trying to run python manage.py makemigrations:
File "manage.py", line 16
) from exc
^
SyntaxError: invalid syntax
Here's my manage.py:
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyDB.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
Now I'll be honest. I may have a clue what the issue is. I'm not using a venv. And I have multiple installations on this system. The problem being I can't remember what I used for this project. I have python 2.7 and python 3. Python 2.7 runs Django 1.11 and python 3 runs django 2.2.7.
When I run manage.py in python 3 it returns the following:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/django/db/backends/mysql/base.py", line 15, in <module>
import MySQLdb as Database
File "/usr/local/lib/python3.6/dist-packages/MySQLdb/__init__.py", line 18, in <module>
from . import _mysql
ImportError: libmariadbclient.so.18: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.6/dist-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/usr/local/lib/python3.6/dist-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.6/dist-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/usr/local/lib/python3.6/dist-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/usr/local/lib/python3.6/dist-packages/django/db/models/base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/usr/local/lib/python3.6/dist-packages/django/db/models/base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/local/lib/python3.6/dist-packages/django/db/models/options.py", line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/usr/local/lib/python3.6/dist-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.6/dist-packages/django/db/backends/mysql/base.py", line 20, in <module>
) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
Now this looks like a database error to me. But I have had this working just fine before with MariaDB. I even performed a full uninstall and reinstall of mariadb by the book from the install guides on the django page and the mariadb page. I'm really at a point of being stuck with this now. Can anyone point me in the right direction?
EDIT: I have tried solutions such as installing pymysql and such from other questions. But I do not seem to be able to find an answer so far
try to run the app using python3 (if you are using python 3.x instead of python only
Hi guys I got a problem when I used command of django-admin startproject mysite, it couldn't work but python -m django startproject mysite is ok.
there has been another problems in my CneOs6.8, when inputed python manage.py migrate, which would :
[root#localhost mysite]# python manage.py migrate
Traceback (most recent call last):
File
"/usr/local/python3.5.0/lib/python3.5/site-
packages/django/db/backends/sqlite3/base.py", line 31, in
from
pysqlite2 import dbapi2 as Database
ImportError: No module named 'pysqlite2'
During
handling of the above exception, another exception occurred:
Traceback (most recent
call last):
File "/usr/local/python3.5.0/lib/python3.5/site-
packages/django/db/backends/sqlite3/base.py", line 33, in
from sqlite3
import dbapi2 as Database
File
"/usr/local/python3.5.0/lib/python3.5/sqlite3/init.py", line 23, in
from sqlite3.dbapi2 import *
File
"/usr/local/python3.5.0/lib/python3.5/sqlite3/dbapi2.py", line 27, in
from _sqlite3 import *
ImportError: No module named '_sqlite3'
During handling of the
above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in
execute_from_command_line(sys.argv)
File
"/usr/local/python3.5.0/lib/python3.5/site-
packages/django/core/management/init.py", line 364, in
execute_from_command_line
utility.execute()
File
"/usr/local/python3.5.0/lib/python3.5/site-
packages/django/core/management/init.py", line 338, in execute
django.setup
()
File "/usr/local/python3.5.0/lib/python3.5/site-packages/django/init.py",
line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File
"/usr/local/python3.5.0/lib/python3.5/site-packages/django/apps/registry.py", line
108, in populate
app_config.import_models()
File
"/usr/local/python3.5.0/lib/python3.5/site-packages/django/apps/config.py", line
202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/python3.5.0/lib/python3.5/importlib/init.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File
"", line 986, in _gcd_import
File "
importlib._bootstrap>", line 969, in _find_and_load
File "
importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "
importlib._bootstrap>", line 673, in _load_unlocked
File "
importlib._bootstrap_external>", line 662, in exec_module
File "
importlib._bootstrap>", line 222, in _call_with_frames_removed
File
"/usr/local/python3.5.0/lib/python3.5/site-packages/django/contrib/auth/models.py",
line 4, in
from django.contrib.auth.base_user import AbstractBaseUser,
BaseUserManager
File "/usr/local/python3.5.0/lib/python3.5/site-
packages/django/contrib/auth/base_user.py", line 52, in
class
AbstractBaseUser(models.Model):
File "/usr/local/python3.5.0/lib/python3.5/site-
packages/django/db/models/base.py", line 124, in new
new_class.add_to_class
('_meta', Options(meta, app_label))
File
"/usr/local/python3.5.0/lib/python3.5/site-packages/django/db/models/base.py", line
325, in add_to_class
value.contribute_to_class(cls, name)
File
"/usr/local/python3.5.0/lib/python3.5/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
"/usr/local/python3.5.0/lib/python3.5/site-packages/django/db/init.py", line
33, in getattr
return getattr(connections[DEFAULT_DB_ALIAS], item)
File
"/usr/local/python3.5.0/lib/python3.5/site-packages/django/db/utils.py", line 211,
in getitem
backend = load_backend(db['ENGINE'])
File
"/usr/local/python3.5.0/lib/python3.5/site-packages/django/db/utils.py", line 115,
in load_backend
return import_module('%s.base' % backend_name)
File
"/usr/local/python3.5.0/lib/python3.5/importlib/init.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File
"/usr/local/python3.5.0/lib/python3.5/site-
packages/django/db/backends/sqlite3/base.py", line 35, in
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): No module named
'_sqlite3'
who can tell my what happend? Tkan you, a million time over. addtionally I wanted you know that I was a new guy in programming.
sqlite3 is not installed.Try to install them
$ pip install sqlite3 # or pysqlite2
try to install lib in your linux OS
sudo apt-get install libsqlite3-dev
then try
pip install pysqlite
I'm trying to set up a Django app using a postgresql server (to eventually use with GeoDjango for GIS). I'm on a mac running OSX 10.11 and am running python 3.5 in a virtualenv. I've gone through all the installtion of postgresql, pyscopg2 etc and am trying to run
python manage.py migrate
But when I do I get the following error.
Traceback (most recent call last):
File "/Users/me/.python3env/lib/python3.5/site-packages/django/db/backends/postgresql/base.py", line 20, in <module>
import psycopg2 as Database
File "/Users/me/.python3env/lib/python3.5/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Users/me/.python3env/lib/python3.5/site-packages/psycopg2/_psycopg.cpython-35m-darwin.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/me/.python3env/lib/python3.5/site-packages/psycopg2/_psycopg.cpython-35m-darwin.so
Reason: image not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/me/.python3env/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/me/.python3env/lib/python3.5/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/Users/me/.python3env/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/me/.python3env/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/me/.python3env/lib/python3.5/site-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/Users/me/.python3env/lib/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 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/me/.python3env/lib/python3.5/site-packages/django/contrib/auth/models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/me/.python3env/lib/python3.5/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "/Users/me/.python3env/lib/python3.5/site-packages/django/db/models/base.py", line 119, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Users/me/.python3env/lib/python3.5/site-packages/django/db/models/base.py", line 316, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/me/.python3env/lib/python3.5/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/me/.python3env/lib/python3.5/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/me/.python3env/lib/python3.5/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/me/.python3env/lib/python3.5/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/Users/me/.python3env/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/me/.python3env/lib/python3.5/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: dlopen(/Users/me/.python3env/lib/python3.5/site-packages/psycopg2/_psycopg.cpython-35m-darwin.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/me/.python3env/lib/python3.5/site-packages/psycopg2/_psycopg.cpython-35m-darwin.so
Reason: image not found
I've found a couple of stackoverflow threads on this error but none of the solutions seem to help at all.
Any advice would be much appreciated!
Edit: brew doctor output
Warning: python is symlinked to python3
This will confuse build scripts and in general lead to subtle breakage.
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Users/me/.python3env/bin/python-config
Warning: Python is installed at /Library/Frameworks/Python.framework
Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.