linux安裝pymssql報錯: error: sqlfront.h: No such file or directory


是在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
終於安裝成功!!!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM