_sqlite3라는 모듈이 없습니다.
Debian 5 를 실행하는 VPS 에서 Django 앱 을 실행하려고 합니다. 데모 앱을 실행하면 다음 오류가 나타납니다.
File "/usr/local/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.5/site-packages/django/db/backends/sqlite3/base.py", line 30, in <module>
raise ImproperlyConfigured, "Error loading %s: %s" % (module, exc)
ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
Python 설치를 보면 동일한 오류가 발생합니다.
Python 2.5.2 (r252:60911, May 12 2009, 07:46:31)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
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/lib/python2.5/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/lib/python2.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
>>>
웹에서 읽으면서 Python 2.5에는 필요한 모든 SQLite 래퍼가 포함되어 있어야한다는 것을 배웠습니다 . Python을 다시 설치해야합니까, 아니면이 모듈을 시작하고 실행하는 다른 방법이 있습니까?
makefile에 적절한 .so
파일이 포함되어 있지 않은 것 같습니다 . 아래 단계에 따라이 문제를 해결할 수 있습니다.
- 설치
sqlite-devel
(또는libsqlite3-dev
일부 Debian 기반 시스템) - 다음을 사용하여 Python을 재구성하고 다시 컴파일합니다.
./configure --enable-loadable-sqlite-extensions && make && sudo make install
노트
이 sudo make install
부분은 해당 파이썬 버전을 시스템 전체 표준으로 설정하여 예기치 않은 결과를 초래할 수 있습니다. 워크 스테이션에서이 명령을 실행 하면 기존 python 과 함께 설치하고 싶을 것입니다 sudo make altinstall
.
나는 동일한 문제 ( python2.5
Ubuntu Lucid의 소스에서 빌드 )가 있었고 import sqlite3
동일한 예외를 던졌습니다. libsqlite3-dev
패키지 관리자에서 설치 하고 python2.5를 다시 컴파일 한 다음 가져 오기가 작동했습니다.
pyenv 를 사용하는 동안 Ubuntu의 Python 3.5에서 동일한 문제가 발생 했습니다 .
pyenv를 사용하여 Python을 설치하는 경우 일반적인 빌드 문제 중 하나로 나열됩니다 . 이 문제를 해결하려면 설치된 Python 버전을 제거하고 요구 사항 (이 특정 경우 libsqlite3-dev
)을 설치 한 다음 Python 버전을 다시 설치하십시오.
이것이 작동하도록하기 위해 내가 한 일입니다.
python 2.7.5가 설치된 pythonbrew (pip 사용)를 사용하고 있습니다.
먼저 Zubair (위)가 말한대로 다음 명령을 실행했습니다.
sudo apt-get install libsqlite3-dev
그런 다음이 명령을 실행했습니다.
pip install pysqlite
이것은 데이터베이스 문제를 해결하고 실행했을 때 이것을 확인했습니다.
python manager.py syncdb
sqlite-devel
패키지를 설치하십시오 :yum install sqlite-devel -y
소스에서 파이썬을 다시 컴파일하십시오.
./configure make make altinstall
내 _sqlite3.so는 /usr/lib/python2.5/lib-dynload/_sqlite3.so에 있습니다. 경로를 보면 /usr/local/lib/python2.5/lib-dynload/_sqlite3.so 파일이 있어야합니다.
다음을 시도하십시오 :
find /usr/local -name _sqlite3.so
If the file isn't found, something may be wrong with your Python installation. If it is, make sure the path it's installed to is in the Python path. In the Python shell,
import sys
print sys.path
In my case, /usr/lib/python2.5/lib-dynload is in the list, so it's able to find /usr/lib/python2.5/lib-dynload/_sqlite3.so.
I found lots of people meet this problem because the Multi-version Python, on my own vps (cent os 7 x64), I solved it in this way:
Find the file "_sqlite3.so"
find / -name _sqlite3.so
out:
/usr/lib64/python2.7/lib-dynload/_sqlite3.so
Find the dir of python Standard library you want to use,
for me
/usr/local/lib/python3.6/lib-dynload
Copy the file:
cp /usr/lib64/python2.7/lib-dynload/_sqlite3.so /usr/local/lib/python3.6/lib-dynload
Finally, everything will be ok.
I recently tried installing python 2.6.7 on my Ubuntu 11.04 desktop for some dev work. Came across similar problems to this thread. I mamaged to fix it by:
Adjusting the setup.py file to include the correct sqlite dev path. Code snippet from setup.py:
def sqlite_incdir: sqlite_dirs_to_check = [ os.path.join(sqlite_incdir, '..', 'lib64'), os.path.join(sqlite_incdir, '..', 'lib'), os.path.join(sqlite_incdir, '..', '..', 'lib64'), os.path.join(sqlite_incdir, '..', '..', 'lib'), '/usr/lib/x86_64-linux-gnu/' ]
With the bit that I added being '/usr/lib/x86_64-linux-gnu/'.
After running make I did not get any warnings saying the sqlite support was not built (i.e., it built correctly :P ), but after running
make install
, sqlite3 still did not import with the same "ImportError: No module named _sqlite3" whe running "import sqlite3
".So, the library was compiled, but not moved to the correct installation path, so I copied the
.so
file (cp /usr/src/python/Python-2.6.7/build/lib.linux-x86_64-2.6/_sqlite3.so /usr/local/python-2.6.7/lib/python2.6/sqlite3/
— these are my build paths, you will probably need to adjust them to your setup).
Voila! SQLite3 support now works.
This worked for me in Redhat Centos 6.5:
yum install sqlite-devel
pip install pysqlite
I have the problem in FreeBSD 8.1:
- No module named _sqlite3 -
It is solved by stand the port ----------
/usr/ports/databases/py-sqlite3
after this one can see:
OK ----------
'>>>' import sqlite3 -----
'>>>' sqlite3.apilevel -----
'2.0'
Checking your settings.py file. Did you not just write "sqlite" instead of "sqlite3" for the database engine?
sqlite3
ships with Python. I also had the same problem, I just uninstalled python3.6
and installed it again.
Uninstall existing python:
sudo apt-get remove --purge python3.6
Install python3.6:
sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
tar xvf Python-3.6.0.tar.xz
cd Python-3.6.0/
./configure
sudo make altinstall
Is the python-pysqlite2 package installed?
sudo apt-get install python-pysqlite2
you must be in centos or redhat and compile python yourself, it is python‘s bug do this in your python source code dir and do this below
curl -sk https://gist.github.com/msabramo/2727063/raw/59ea097a1f4c6f114c32f7743308a061698b17fd/gistfile1.diff | patch -p1
I got the same problem, nothing worked for me from the above ans but now I fixed it by
just remove python.pip
and sqlite3
and reinstall
sudo apt-get remove python.pip
sudo apt-get remove sqlite3
now install it again
sudo apt-get install python.pip
sudo apt-get install sqlite3
in my case while installing sqlite3
again it showed some error then I typed
sqlite3
on terminal to check if it was removed or not and it started unpacking it
once the sqlite3
is installed fireup terminal and write
sqlite3
database.db
(to create a database)
I'm sure this will definitely help you
Download sqlite3:
wget http://www.sqlite.org/2016/sqlite-autoconf-3150000.tar.gz
Follow these steps to install:
$tar xvfz sqlite-autoconf-3071502.tar.gz
$cd sqlite-autoconf-3071502
$./configure --prefix=/usr/local
$make install
Try copying _sqlite3.so
so that Python can find it.
It should be as simple as:
cp /usr/lib64/python2.6/lib-dynload/_sqlite3.so /usr/local/lib/python2.7/
Trust me, try it.
You need to install pysqlite in your python environment:
$ pip install pysqlite
참고URL : https://stackoverflow.com/questions/1210664/no-module-named-sqlite3
'IT story' 카테고리의 다른 글
Javascript를 사용하여 IFrame을 새로 고치는 방법? (0) | 2020.08.07 |
---|---|
유창함 / 유창함을 사용하여 단일 쿼리에서 여러 행을 삽입하는 방법 (0) | 2020.08.07 |
빈 RequestParam 값이 defaultValue를 사용하도록 할 수 있습니까? (0) | 2020.08.07 |
R : rJava 패키지 설치 실패 (0) | 2020.08.07 |
TypeScript를 사용한 개방형 함수 인수 (0) | 2020.08.07 |