是在alpine容器中安装pymssql,一直报错
报错信息如下:
Collecting pymssql Downloading pymssql-2.2.4.tar.gz (169 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 169.9/169.9 KB 33.9 kB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: pymssql Building wheel for pymssql (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for pymssql (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [17 lines of output] setup.py: platform.system() => Linux setup.py: platform.architecture() => ('64bit', 'ELF') setup.py: platform.libc_ver() => ('', '') setup.py: include_dirs => [] setup.py: library_dirs => [] running bdist_wheel running build running build_py running build_ext cythoning src/pymssql/_mssql.pyx to src/pymssql/_mssql.c cythoning src/pymssql/_pymssql.pyx to src/pymssql/_pymssql.c building 'pymssql._mssql' extension src/pymssql/_mssql.c:682:10: fatal error: sqlfront.h: No such file or directory 682 | #include "sqlfront.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 pymssql Failed to build pymssql ERROR: Could not build wheels for pymssql, which is required to install pyproject.toml-based projects
解决方式:
注意:之前试过直接下载freetds包的形式安装,是不行的,需用容器命令安装
参考连接:https://blog.csdn.net/qq_41185868/article/details/80724240
后面查了下,是因为
export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1,设置这个环境变量成功的
先进入容器 sudo docker exec -it bc bash export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1 然后运行以下命令,安装freetds apk add freetds-dev pip3 --no-cache-dir install pymssql
终于安装成功!!!