반응형
1. ModuleNotFoundError: No module named '_sqlite3'
* pyenv 환경에서 진행
# python manage.py createuperuser
...
packages/django/utils/connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "/root/.pyenv/versions/venv_3.9.4/lib/python3.9/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/root/.pyenv/versions/venv_3.9.4/lib/python3.9/site-packages/django/db/utils.py", line 208, in create_connection
backend = load_backend(db["ENGINE"])
File "/root/.pyenv/versions/venv_3.9.4/lib/python3.9/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/root/.pyenv/versions/3.9.4/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/root/.pyenv/versions/venv_3.9.4/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 15, in <module>
from sqlite3 import dbapi2 as Database
File "/root/.pyenv/versions/3.9.4/lib/python3.9/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/root/.pyenv/versions/3.9.4/lib/python3.9/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
# python
Python 3.9.4 (default, Jul 7 2022, 23:21:40)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/.pyenv/versions/3.9.4/lib/python3.9/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/root/.pyenv/versions/3.9.4/lib/python3.9/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
-> yum install sqlite sqlite-devel
pyenv 환경 다시 재설치
# CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.9.4
sqlite3 버전확인.
# python3
Python 3.9.4 (default, Jul 10 2022, 14:34:24)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.7.17'
2. django.core.exceptions.ImproperlyConfigured: SQLite 3.9.0 or later is required (found 3.7.17).
-> 최신버전 sqlite 설치
wget https://sqlite.org/2022/sqlite-autoconf-3390000.tar.gz
tar xvfz sqlite-autoconf-3390000.tar.gz
cd sqlite-autoconf-3390000
./configure --prefix=/usr/local/
make && make install
cp -arp /usr/local/bin/sqlite3 /usr/bin/sqlite3
sqlite3 --version
3.39.0 2022-06-25 14:57:57 14e166f40dbfa6e055543f8301525f2ca2e96a02a57269818b9e69e162e98918
그러나 PYTHON 버전에서 sqlite로 했을 때에는 기존 버전을 바라보고 있다.
# python3
Python 3.9.4 (default, Jul 10 2022, 14:34:24)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.7.17'
라이브러리 위치를 최신버전을 설치한 sqlite3쪽으로 향하게 해준다.
# echo $LD_LIBRARY_PATH
# export LD_LIBRARY_PATH="/usr/local/lib"
# echo $LD_LIBRARY_PATH
/usr/local/lib
영구적으로 라이브러리 위치를 지정하고 싶다면
# vi /etc/ld.so.conf.d/sqlite.conf
/usr/local/lib
# python3
Python 3.9.4 (default, Jul 10 2022, 14:34:24)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.39.0'
반응형
'DEV' 카테고리의 다른 글
pip 버전업시 에러 def read(rel_path: str) -> str:^SyntaxError: invalid syntax (0) | 2022.11.04 |
---|---|
[Python] does not support timestamps before 1980 (1) | 2022.10.23 |
[PYTHON] pyenv 가상환경 셋팅 (0) | 2022.07.08 |
[Sentry] 도메인 연결 및 SSL 설정 (0) | 2022.06.19 |
[Sentry] MAIL 서버 설정 (0) | 2022.06.19 |