首页 > 解决方案 > 为什么我的 jenkins 服务器上不同用户的 sqlite 版本不同?

问题描述

作为詹金斯用户,我sqlite_version3.7.17

bash-4.2$ python3.8
Python 3.8.2 (default, May  8 2020, 12:44:28) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3 
>>> sqlite3.sqlite_version
'3.7.17'

sqlite_version作为我的根用户3.31.1

[root@jenkins ~]# python3.8
Python 3.8.2 (default, May  8 2020, 12:44:28) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.31.1'

他们都使用相同的python二进制文件

[root@jenkins ~]# which python3.8
/usr/local/bin/python3.8

bash-4.2$ which python3.8
/usr/local/bin/python3.8

从源代码安装新的 sqlite3 后我采取的步骤:

你知道如何让 jenkins python 使用新的 sqlite3 版本吗?

更新:

运行sqlite3.__file__

詹金斯

>>> sqlite3.__file__
'/usr/local/lib/python3.8/sqlite3/__init__.py'

>>> sqlite3.__file__
'/usr/local/lib/python3.8/sqlite3/__init__.py'

标签: python-3.xsqlitejenkins

解决方案


以下适用于 CentOS 7.7:


安装 Python 依赖项

sudo yum -y groupinstall 'Development Tools'
sudo yum -y install openssl-devel bzip2-devel libffi-devel

SQLite 源安装

wget https://sqlite.org/2020/sqlite-autoconf-3310100.tar.gz
tar -xf sqlite-autoconf-3310100.tar.gz
cd sqlite-autoconf-3310100/
./configure
make
sudo make install

Python源安装

wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz
tar -xf Python-3.8.2.tar.xz
cd Python-3.8.2/
sudo LD_RUN_PATH=/usr/local/lib ./configure --enable-optimizations
sudo LD_RUN_PATH=/usr/local/lib make altinstall

测试

[centos@jenkins ~]$ sudo su
[root@jenkins centos]# id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@jenkins centos]# grep PATH /root/.bashrc
export PATH=$PATH:/usr/local/bin
[root@jenkins centos]# python3.8
Python 3.8.2 (default, May 15 2020, 07:26:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.31.1'
>>> sqlite3.__file__
'/usr/local/lib/python3.8/sqlite3/__init__.py'
>>>

[root@jenkins centos]# exit
[centos@jenkins ~]$
[centos@jenkins ~]$ sudo su - jenkins
Last login: Fri May 15 07:44:53 UTC 2020 on pts/0
-bash-4.2$ id
uid=996(jenkins) gid=993(jenkins) groups=993(jenkins) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
-bash-4.2$ pwd
/var/lib/jenkins
-bash-4.2$ grep PATH .bashrc
grep: .bashrc: No such file or directory
-bash-4.2$ python3.8
Python 3.8.2 (default, May 15 2020, 07:26:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.31.1'
>>> sqlite3.__file__
'/usr/local/lib/python3.8/sqlite3/__init__.py'
>>>

推荐阅读