Microsoft MVP성태의 닷넷 이야기
오류 유형: 865. 파이썬 - pymssql 설치 관련 오류 정리 [링크 복사], [링크+제목 복사],
조회: 4630
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)

파이썬 - pymssql 설치 관련 오류 정리

원래 설치는 이렇게 끝낼 수 있습니다.

$ python -m pip install pymssql
Defaulting to user installation because normal site-packages is not writeable
Collecting pymssql
  Downloading pymssql-2.2.7-cp311-cp311-manylinux_2_24_x86_64.whl (3.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 8.8 MB/s eta 0:00:00
Installing collected packages: pymssql
Successfully installed pymssql-2.2.7




Python 3.8의 경우 2.1.0 ~ 2.1.4 버전을 설치할 때 이런 오류가 발생할 수 있습니다.

# pip install pymssql==2.1.0
Collecting pymssql==2.1.0
  Using cached pymssql-2.1.0.zip (2.5 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [10 lines of output]
      /usr/local/lib/python3.8/site-packages/setuptools/dist.py:51: DistDeprecationWarning: Do not call this function
        warnings.warn("Do not call this function", DistDeprecationWarning)
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-r3vg2u62/pymssql_48a48fb60ec742fca2da191448d9bc72/setup.py", line 131, in <module>
          print("setup.py: platform.linux_distribution() => %r" % (platform.linux_distribution(),))
      AttributeError: module 'platform' has no attribute 'linux_distribution'
      setup.py: platform.system() => 'Linux'
      setup.py: platform.architecture() => ('64bit', 'ELF')
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Python 3.7부터 완전히 삭제된 platform.linux_distribution을 사용하기 때문인데, 2.1.5 버전에서 수정했다고 합니다. 따라서 Python을 3.6 이하로 내리든가, 아니면 pymssql 버전을 2.1.5 이상의 버전을 사용해야 합니다.




파이썬의 버전에 따라 2.0.0 ~ 2.2.0 버전을 설치하는 경우 다음의 문제가 발생한다면?

$ python3.11 -m pip install pymssql==2.2.0
...[생략]...
      x86_64-linux-gnu-gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.11 -c src/pymssql/_mssql.c -o build/temp.linux-x86_64-cpython-311/src/pymssql/_mssql.o -DMSDBLIB
      src/pymssql/_mssql.c:747:10: fatal error: sqlfront.h: No such file or directory
        747 | #include "sqlfront.h"
            |          ^~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-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

다행히 해결 방법이 있고,

failed to build: Cannot open include file: 'sqlfront.h': No such file or directory #372
; https://github.com/pymssql/pymssql/issues/372

Ubuntu의 경우, freetds-dev를 다음과 같이 설치하면 됩니다.

$ sudo apt install freetds-dev




마지막으로 2.0.0 버전 이하를 설치하면 아래와 같이 복잡한 오류가 발생하는 경우도 있을 것입니다.

# pip install pymssql==2.0.0
Collecting pymssql==2.0.0
  Using cached pymssql-2.0.0.zip (2.4 MB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o_z_7v5i/pymssql_35aeb37a9a8e46b098a7d5cbf4b78fbb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o_z_7v5i/pymssql_35aeb37a9a8e46b098a7d5cbf4b78fbb/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-dcnnrk4u
       cwd: /tmp/pip-install-o_z_7v5i/pymssql_35aeb37a9a8e46b098a7d5cbf4b78fbb/
  Complete output (14 lines):
  /usr/local/lib/python3.6/site-packages/setuptools/dist.py:51: DistDeprecationWarning: Do not call this function
    warnings.warn("Do not call this function", DistDeprecationWarning)
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-o_z_7v5i/pymssql_35aeb37a9a8e46b098a7d5cbf4b78fbb/setup.py", line 412, in <module>
      long_description = open('README.rst').read() +"\n\n" + open('ChangeLog_highlights.rst').read(),
  FileNotFoundError: [Errno 2] No such file or directory: 'ChangeLog_highlights.rst'
  setup.py: platform.system() => 'Linux'
  setup.py: platform.architecture() => ('64bit', 'ELF')
  setup.py: platform.linux_distribution() => ('debian', '10.12', '')
  setup.py: platform.libc_ver() => ('glibc', '2.2.5')
  setup.py: Not using bundled FreeTDS
  setup.py: include_dirs = ['/usr/local/include']
  setup.py: library_dirs = ['/usr/local/lib']
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/43/8a/39276b764d4f57ea1950c600a87c567ab5e1ec70c646390084f9a26ec74e/pymssql-2.0.0.zip#sha256=848341594f399d9cf6dd47663e01403b22ac6cffe80914d10f3b6cc1dd43b8f4 (from https://pypi.org/simple/pymssql/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached pymssql-2.0.0.tar.gz (2.4 MB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pymssql
  Building wheel for pymssql (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o_z_7v5i/pymssql_3da1f94548ef4cc7be30c239703c18ae/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o_z_7v5i/pymssql_3da1f94548ef4cc7be30c239703c18ae/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-rs7um03z
       cwd: /tmp/pip-install-o_z_7v5i/pymssql_3da1f94548ef4cc7be30c239703c18ae/
  Complete output (27 lines):
  /usr/local/lib/python3.6/site-packages/setuptools/dist.py:51: DistDeprecationWarning: Do not call this function
    warnings.warn("Do not call this function", DistDeprecationWarning)
  setup.py: platform.system() => 'Linux'
  setup.py: platform.architecture() => ('64bit', 'ELF')
  setup.py: platform.linux_distribution() => ('debian', '10.12', '')
  setup.py: platform.libc_ver() => ('glibc', '2.2.5')
  setup.py: Not using bundled FreeTDS
  setup.py: include_dirs = ['/usr/local/include']
  setup.py: library_dirs = ['/usr/local/lib']
  running bdist_wheel
  running build
  running build_ext
  building '_mssql' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include -I/usr/local/include/python3.6m -c _mssql.c -o build/temp.linux-x86_64-3.6/_mssql.o -DMSDBLIB
  _mssql.c: In function ‘__pyx_f_6_mssql__tds_ver_str_to_constant’:
  _mssql.c:15426:15: error: ‘DBVERSION_80’ undeclared (first use in this function); did you mean ‘DBVERSION_70’?
       __pyx_r = DBVERSION_80;
                 ^~~~~~~~~~~~
                 DBVERSION_70
  _mssql.c:15426:15: note: each undeclared identifier is reported only once for each function it appears in
  At top level:
  _mssql.c:3331:12: warning: ‘__pyx_f_6_mssql_db_sqlexec’ defined but not used [-Wunused-function]
   static int __pyx_f_6_mssql_db_sqlexec(DBPROCESS *__pyx_v_dbproc) {
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pymssql
  Running setup.py clean for pymssql
Failed to build pymssql
Installing collected packages: pymssql
    Running setup.py install for pymssql ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o_z_7v5i/pymssql_3da1f94548ef4cc7be30c239703c18ae/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o_z_7v5i/pymssql_3da1f94548ef4cc7be30c239703c18ae/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-yql3imw_/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/pymssql
         cwd: /tmp/pip-install-o_z_7v5i/pymssql_3da1f94548ef4cc7be30c239703c18ae/
    Complete output (27 lines):
    /usr/local/lib/python3.6/site-packages/setuptools/dist.py:51: DistDeprecationWarning: Do not call this function
      warnings.warn("Do not call this function", DistDeprecationWarning)
    setup.py: platform.system() => 'Linux'
    setup.py: platform.architecture() => ('64bit', 'ELF')
    setup.py: platform.linux_distribution() => ('debian', '10.12', '')
    setup.py: platform.libc_ver() => ('glibc', '2.2.5')
    setup.py: Not using bundled FreeTDS
    setup.py: include_dirs = ['/usr/local/include']
    setup.py: library_dirs = ['/usr/local/lib']
    running install
    running build
    running build_ext
    building '_mssql' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include -I/usr/local/include/python3.6m -c _mssql.c -o build/temp.linux-x86_64-3.6/_mssql.o -DMSDBLIB
    _mssql.c: In function ‘__pyx_f_6_mssql__tds_ver_str_to_constant’:
    _mssql.c:15426:15: error: ‘DBVERSION_80’ undeclared (first use in this function); did you mean ‘DBVERSION_70’?
         __pyx_r = DBVERSION_80;
                   ^~~~~~~~~~~~
                   DBVERSION_70
    _mssql.c:15426:15: note: each undeclared identifier is reported only once for each function it appears in
    At top level:
    _mssql.c:3331:12: warning: ‘__pyx_f_6_mssql_db_sqlexec’ defined but not used [-Wunused-function]
     static int __pyx_f_6_mssql_db_sqlexec(DBPROCESS *__pyx_v_dbproc) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o_z_7v5i/pymssql_3da1f94548ef4cc7be30c239703c18ae/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o_z_7v5i/pymssql_3da1f94548ef4cc7be30c239703c18ae/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-yql3imw_/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/pymssql Check the logs for full command output.

아래의 글에도 나오지만,

pymssql-2.1.3 ‘DBVERSION_80’ undeclared (first use in this function); did you mean ‘DBVERSION_70’? 
; https://github.com/pymssql/pymssql/issues/520

"/usr/include/sybdb.h" 파일의 내용에서 DBVERSION_80 상수를 이런 식으로,

#define DBVERSION_80 DBVERSION_71

추가해 주면 됩니다. 혹은 그냥, 아예 2.1.4 버전을 설치하는 것이 더 좋겠습니다.




이후 대략적인 사용법은 아래의 글을 참고하시고. ^^

MSSQL 사용
; http://pythonstudy.xyz/python/article/208-MSSQL-사용




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 8/10/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13386정성태6/27/20233798Linux: 61. docker - 원격 제어를 위한 TCP 바인딩 추가
13385정성태6/27/20234025Linux: 60. Linux - 외부에서의 접속을 허용하기 위한 TCP 포트 여는 방법
13384정성태6/26/20233746.NET Framework: 2131. C# - Source Generator로 해결하는 enum 박싱 문제파일 다운로드1
13383정성태6/26/20233495개발 환경 구성: 683. GPU 런타임을 사용하는 Colab 노트북 설정
13382정성태6/25/20233547.NET Framework: 2130. C# - Win32 API를 이용한 윈도우 계정 정보 (예: 마지막 로그온 시간)파일 다운로드1
13381정성태6/25/20233964오류 유형: 869. Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
13380정성태6/24/20233387스크립트: 52. 파이썬 3.x에서의 동적 함수 추가
13379정성태6/23/20233430스크립트: 51. 파이썬 2.x에서의 동적 함수 추가
13378정성태6/22/20233314오류 유형: 868. docker - build 시 "CANCELED ..." 뜨는 문제
13377정성태6/22/20237184오류 유형: 867. 파이썬 mysqlclient 2.2.x 설치 시 "Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually" 오류
13376정성태6/21/20233553.NET Framework: 2129. C# - Polly를 이용한 클라이언트 측의 요청 재시도파일 다운로드1
13375정성태6/20/20233215스크립트: 50. Transformers (신경망 언어모델 라이브러리) 강좌 - 2장 코드 실행 결과
13374정성태6/20/20233317오류 유형: 866. 파이썬 - <class 'AttributeError'> module 'flask.json' has no attribute 'JSONEncoder'
13373정성태6/19/20234630오류 유형: 865. 파이썬 - pymssql 설치 관련 오류 정리
13372정성태6/15/20233258개발 환경 구성: 682. SQL Server TLS 통신을 위해 사용되는 키 길이 확인 방법
13371정성태6/15/20233322개발 환경 구성: 681. openssl - 인증서 버전(V1 / V3)
13370정성태6/14/20233484개발 환경 구성: 680. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 - TLS 1.2 지원
13369정성태6/13/20233296개발 환경 구성: 679. PyCharm(을 비롯해 JetBrains에 속한 여타) IDE에서 내부 Window들의 탭이 없어진 경우
13368정성태6/13/20233447개발 환경 구성: 678. openssl로 생성한 인증서를 SQL Server의 암호화 인증서로 설정하는 방법
13367정성태6/10/20233588오류 유형: 864. openssl로 만든 pfx 인증서를 Windows Server 2016 이하에서 등록 시 "The password you entered is incorrect" 오류 발생
13366정성태6/10/20233325.NET Framework: 2128. C# - 윈도우 시스템에서 지원하는 암호화 목록(Cipher Suites) 나열파일 다운로드1
13365정성태6/8/20233068오류 유형: 863. MODIFY FILE encountered operating system error 112(failed to retrieve text for this error. Reason: 15105)
13364정성태6/8/20233882.NET Framework: 2127. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 [1]
13363정성태6/7/20233473스크립트: 49. 파이썬 - "Transformers (신경망 언어모델 라이브러리) 강좌" - 1장 2절 코드 실행 결과
13362정성태6/1/20233382.NET Framework: 2126. C# - 서버 측의 요청 제어 (Microsoft.AspNetCore.RateLimiting)파일 다운로드1
13361정성태5/31/20233813오류 유형: 862. Facebook - ASP.NET/WebClient 사용 시 graph.facebook.com/me 호출에 대해 403 Forbidden 오류
1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...