Python django 找不到新的 sqlite 版本?(需要 SQLite 3.8.3 或更高版本(找到 3.7.17))
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/55674176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
django can't find new sqlite version? (SQLite 3.8.3 or later is required (found 3.7.17))
提问by SIMMORSAL
I've cloned a django project to a Centos 7 vps and I'm trying to run it now, but I get this error when trying to migrate
:
我已经将 django 项目克隆到 Centos 7 vps 并且我现在正在尝试运行它,但是在尝试时出现此错误migrate
:
$ python manage.py migrate
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).
When I checked the version for sqlite, it was 3.7.17, so I downloaded the newest version from sqlite website and replaced it with the old one, and now when I version it, it gives:
当我检查 sqlite 的版本时,它是 3.7.17,所以我从 sqlite 网站下载了最新版本并将其替换为旧版本,现在当我对其进行版本控制时,它给出:
$ sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7
Still when I try to migrate the project, I get the exact same message as before which means the newer version is not found. I'm new to linux and would appreciate any help.
尽管如此,当我尝试迁移项目时,我收到与之前完全相同的消息,这意味着找不到较新的版本。我是 linux 新手,希望得到任何帮助。
采纳答案by Mark Bailey
To check which version of SQLite Python is using:
要检查使用的是哪个版本的 SQLite Python:
$ python
Python 3.7.3 (default, Apr 12 2019, 16:23:13)
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.27.2'
For me the new version of sqlite3 is in /usr/local/bin so I had to recompile Python, telling it to look there:
对我来说,sqlite3 的新版本在 /usr/local/bin 中,所以我不得不重新编译 Python,告诉它在那里查看:
sudo LD_RUN_PATH=/usr/local/lib ./configure --enable-optimizations
sudo LD_RUN_PATH=/usr/local/lib make altinstall
I hope that helps.
我希望这有帮助。
回答by Kushan Gunasekera
I got the same error in CentOS 7.6and Python 3.7.3versions. I think you are using Django 2.2.*some version. In latest of Django 2.2, they changed the SQLIteversion, that cause of your problem.
我在CentOS 7.6和Python 3.7.3版本中遇到了同样的错误。我认为您正在使用Django 2.2.*某个版本。在最新的Django 2.2 中,他们更改了SQLIte版本,这是导致您出现问题的原因。
This is the release notesof Django 2.2about SQLite.
这是发行说明的Django的2.2左右的SQLite。
The minimum supported version of SQLite is increased from 3.7.15 to 3.8.3.
SQLite 支持的最低版本从 3.7.15 增加到 3.8.3。
So you can install latest version of Django 2.1by using this command.
因此,您可以使用此命令安装最新版本的Django 2.1。
pip install Django==2.1.*
I think the problem is solved.
我认为问题解决了。
回答by Laenka-Oss
I solved a similar situation with the following patches of code. Follow these steps that I used on my own centos7 & everything should be alright.
Just remember to let your centos7 know that you are calling python3
not just python
otherwise it will call the default python2 followed by a series of errors in your virtualenv
.
我用以下代码补丁解决了类似的情况。按照我在自己的 centos7 上使用的这些步骤进行操作,一切都应该没问题。请记住让您的 centos7 知道您正在调用python3
,python
否则它会调用默认的 python2,然后在您的virtualenv
.
Installing python3 (from source):
安装 python3(来自源代码):
cd ~
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
tar xJf Python-3.7.3.tar.xz
cd Python-3.7.3
./configure
make && make install
export PATH=$HOME/opt/python-3.7.3/bin:$PATH
Then run: source .bash_profile
然后运行: source .bash_profile
Confirming by
确认者
python3 --version
Python 3.7.3
Installing your sqlite3 (from source):
安装您的 sqlite3(来自源代码):
$ cd ~
$ wget https://www.sqlite.org/2019/sqlite-autoconf-3290000.tar.gz
$ tar zxvf sqlite-autoconf-3290000.tar.gz
cd sqlite-autoconf-3290000
$./configure --prefix=$HOME/opt/sqlite
$ make && make install
Now this is what you should also remember to do for centos7 know where to look for your python3 and not defaulting to python2. On your .bash_profile
copy & past this piece of code or edit the paths accordingly:
现在这也是你应该记住的事情,让 centos7 知道在哪里寻找你的 python3 而不是默认为 python2。在您的.bash_profile
副本上并通过这段代码或相应地编辑路径:
export PATH=$HOME/opt/sqlite/bin:$PATH
export LD_LIBRARY_PATH=$HOME/opt/sqlite/lib
export LD_RUN_PATH=$HOME/opt/sqlite/lib
Make it permanent by running: source .bash_profile
and you are done with sqlite3 version >= 3.8
. Confirm it by:
通过运行使其永久化:source .bash_profile
你就完成了sqlite3 version >= 3.8
. 通过以下方式确认:
sqlite3 --version
3.29.0 2019-07-10 17:32:03
And then you can continue to use python3 to install python3 modules like django-2.2.
然后就可以继续使用python3来安装django-2.2之类的python3模块了。
python3.7 -m pip3 install virtualenv
(myvenv37)[me@test my_project]$ python3.7 -m pip3 install django
Successfully installed django-2.2.3 pytz-2019.1 sqlparse-0.3.0
Remember, it is
记住,它是
PYTHON3.7 -m pip3 install MODULE
PYTHON3.7 -m pip3 install MODULE
(myvenv37)[me@test my_project]$ python3.7 manage.py runserver
and the server should be running.
并且服务器应该正在运行。
So, to conclude, in the case above it was migrate
, & should look like this:
所以,总而言之,在上面的例子中,它是migrate
, & 应该是这样的:
(venv)[me@test my_project]$ python3.7 manage.py migrate
回答by pumpkindle
django 2.2need sqlite version >= 3.8.3
django 2.2需要 sqlite 版本 >= 3.8.3
so the solution is update your sqlite:
所以解决方案是更新你的sqlite:
- download from sqlite3, select source_code version
- tar -zxvf sqlite-xxx.tar.gz && cd xx
- ./configure && make && make install
- mv /usr/bin/sqlite3 /usr/bin/sqlite3.bak
- mv xxx/sqlite3 /usr/bin/sqlite3
export LD_LIBRARY_PATH="/usr/local/lib"
and write it into ~/.bashrc
- 从sqlite3下载,选择 source_code 版本
- tar -zxvf sqlite-xxx.tar.gz && cd xx
- ./configure && make && make install
- mv /usr/bin/sqlite3 /usr/bin/sqlite3.bak
- mv xxx/sqlite3 /usr/bin/sqlite3
export LD_LIBRARY_PATH="/usr/local/lib"
并将其写入 ~/.bashrc
test1 :
测试1:
sqlite3 --version
should be your version
应该是你的版本
test2:
测试2:
$python
>>> import sqlite3
>>> sqlite3.sqlite_version
should be your version
应该是你的版本
回答by Wojtek
I had the same issue and I struggled with it for a while. For me the best solution was to comment out DATABASES section in settings.py file.
我遇到了同样的问题,并为此挣扎了一段时间。对我来说,最好的解决方案是注释掉 settings.py 文件中的 DATABASES 部分。
As I don't want to use SQLite database then issue does not exist anymore. Later on you can update DATABASE information with the db that is valid for you.
由于我不想使用 SQLite 数据库,因此问题不再存在。稍后您可以使用对您有效的数据库更新 DATABASE 信息。
回答by Stavinsky
another option is to use atomic repo
另一种选择是使用原子回购
wget -O - http://updates.atomicorp.com/installers/atomic |sh
yum install atomic-sqlite
LD_LIBRARY_PATH='/opt/atomicorp/atomic/root/usr/lib64/' python3
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.8.5'