在pycharm中写好代码,为让代码能在jenkins中构建并运行,linux中也需要安装所需包。
其中安装sqlite3有关包时报错,这里是没有sqlite3这个包,实际上应该下载pysqlite3:
root@d6a2438720b1:/var/jenkins_home/workspace/douyin_down# pip3 install sqlite3
ERROR: Could not find a version that satisfies the requirement sqlite3 (from versions: none)
ERROR: No matching distribution found for sqlite3
下载pysqlite3仍然报错,缺少必要组件
root@d6a2438720b1:/var/jenkins_home/workspace/douyin_down# pip3 install pysqlite3
Collecting pysqlite3
Using cached pysqlite3-0.5.2.tar.gz (40 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pysqlite3
Building wheel for pysqlite3 (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pysqlite3 (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-38
creating build/lib.linux-x86_64-cpython-38/pysqlite3
copying pysqlite3/__init__.py -> build/lib.linux-x86_64-cpython-38/pysqlite3
copying pysqlite3/dbapi2.py -> build/lib.linux-x86_64-cpython-38/pysqlite3
running build_ext
Builds a C extension linking against libsqlite3 library
building 'pysqlite3._sqlite3' extension
creating build/temp.linux-x86_64-cpython-38
creating build/temp.linux-x86_64-cpython-38/src
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DMODULE_NAME=\"pysqlite3.dbapi2\" -I/usr/include -I/usr/local/include/python3.8 -c src/blob.c -o build/temp.linux-x86_64-cpython-38/src/blob.o
In file included from src/blob.c:1:
src/blob.h:4:10: fatal error: sqlite3.h: No such file or directory
4 | #include "sqlite3.h"
| ^~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pysqlite3
Failed to build pysqlite3
ERROR: Could not build wheels for pysqlite3, which is required to install pyproject.toml-based projects
解决方案:
下载并更新setuptools
root@d6a2438720b1:/var/jenkins_home/workspace/douyin_down# sudo pip3 install --upgrade setuptools
Requirement already satisfied: setuptools in /usr/local/lib/python3.8/site-packages (49.2.1)
Collecting setuptools
Using cached setuptools-70.0.0-py3-none-any.whl.metadata (5.9 kB)
Using cached setuptools-70.0.0-py3-none-any.whl (863 kB)
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 49.2.1
Uninstalling setuptools-49.2.1:
Successfully uninstalled setuptools-49.2.1
Successfully installed setuptools-70.0.0
再次下载即可
root@d6a2438720b1:/var/jenkins_home/workspace/douyin_down# sudo apt-get install libsqlite3-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
build-essential dpkg-dev fakeroot g++ g++-12 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libexpat1-dev libfakeroot libpython3-dev libpython3.11 libpython3.11-dev
libstdc++-12-dev python3-dev python3-wheel python3.11-dev
Use 'sudo apt autoremove' to remove them.
Suggested packages:
sqlite3-doc
The following NEW packages will be installed:
libsqlite3-dev
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 1025 kB of archives.
After this operation, 3225 kB of additional disk space will be used.
Get:1 https://mirrors.aliyun.com/debian bookworm/main amd64 libsqlite3-dev amd64 3.40.1-2 [1025 kB]
Fetched 1025 kB in 1s (1747 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libsqlite3-dev:amd64.
(Reading database ... 35741 files and directories currently installed.)
Preparing to unpack .../libsqlite3-dev_3.40.1-2_amd64.deb ...
Unpacking libsqlite3-dev:amd64 (3.40.1-2) ...
Setting up libsqlite3-dev:amd64 (3.40.1-2) ...
root@d6a2438720b1:/var/jenkins_home/workspace/douyin_down# sudo pip3 install pysqlite3
Collecting pysqlite3
Using cached pysqlite3-0.5.2.tar.gz (40 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pysqlite3
Building wheel for pysqlite3 (pyproject.toml) ... done
Created wheel for pysqlite3: filename=pysqlite3-0.5.2-cp38-cp38-linux_x86_64.whl size=156127 sha256=ec36e4eccc2f4922a5d4c98bd6fbe4a4a559172788507e2ea4e44f9dff5fd62c
Stored in directory: /root/.cache/pip/wheels/2c/94/23/ea4dae283fe0772dc65dcb6f20d6655dd2737c4c0ef5850b89
Successfully built pysqlite3
Installing collected packages: pysqlite3
Successfully installed pysqlite3-0.5.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv