Microsoft MVP성태의 닷넷 이야기
오류 유형: 874. 파이썬 - pymssql을 윈도우 환경에서 설치 불가 [링크 복사], [링크+제목 복사],
조회: 3807
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

파이썬 - pymssql을 윈도우 환경에서 설치 불가

이 글은 해법을 제시하지 않고, 단지 해결을 위한 중간 단계까지의 시행착오만 담고 있습니다.




아쉽게도 pymssql은 윈도우 환경에서 (제가 방법을 모르는 걸 수도 있지만) 설치가 안 됩니다. 일단 시도를 해보면,

c:\temp> python --version
Python 3.7.3

c:\temp> python -m pip install pymssql
Collecting pymssql
  Downloading pymssql-2.2.8.tar.gz (171 kB)
     |████████████████████████████████| 171 kB 6.4 MB/s
  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: Command errored out with exit status 1:
   command: 'C:\Python37\python.exe' 'C:\Python37\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel '%USERPROFILE%\AppData\Local\Temp\tmpw6373io1'
       cwd: %USERPROFILE%\AppData\Local\Temp\pip-install-k5o2dacd\pymssql_49532f5aeab24dd8aff035d1baba3af9
  Complete output (41 lines):
  setup.py: platform.system() => Windows
  setup.py: platform.architecture() => ('64bit', 'WindowsPE')
  setup.py: include_dirs => []
  setup.py: library_dirs => []
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-cpython-37
  creating build\lib.win32-cpython-37\pymssql
  copying src\pymssql\__init__.py -> build\lib.win32-cpython-37\pymssql
  running build_ext
  Compiling src\pymssql\_mssql.pyx because it changed.
  [1/1] Cythonizing src\pymssql\_mssql.pyx
  building 'pymssql._mssql' extension
  creating build\temp.win32-cpython-37
  creating build\temp.win32-cpython-37\Release
  creating build\temp.win32-cpython-37\Release\src
  creating build\temp.win32-cpython-37\Release\src\pymssql
  "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Python37\include -IC:\Python37\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcsrc\pymssql\_mssql.c /Fobuild\temp.win32-cpython-37\Release\src\pymssql\_mssql.obj -DMSDBLIB
  _mssql.c
  src\pymssql\_mssql.c(1139): fatal error C1083: Cannot open include file: 'sqlfront.h': No such file or directory
  warning: src\pymssql\_mssql.pyx:27:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:28:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:29:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:30:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:31:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:32:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:35:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:36:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:38:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:82:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:230:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:264:4: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:333:4: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:831:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:919:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:1005:12: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:1379:16: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:1713:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x86\\cl.exe' failed with exit code 2
  ----------------------------------------
  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
WARNING: You are using pip version 21.3.1; however, version 23.2.1 is available.
You should consider upgrading via the 'C:\Python37\python.exe -m pip install --upgrade pip' command.

복잡한 오류 메시지 속에 이번에도 "fatal error C1083: Cannot open include file: 'sqlfront.h': No such file or directory" 문제가 나옵니다. 따라서 아래의 글에 따라,

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

(리눅스에서 freetds-dev를 설치한 것처럼) x86의 경우, freetds-v0.95.95-win-x86-vs2015.zip을, x64의 경우 freetds-v0.95.95-win-x86_64-vs2015.zip을 다운로드해 압축을 풀어 INCLUDE, LIB 환경 변수를 연결해 줍니다. 아래는 요즘 세상에 x86을 쓰진 않을 테니 x64를 기준으로 환경 구성을 가정합니다.

// Visual Studio 2022의 "x64 Native Tools Command Prompt" 창을 열고,
// 여기서는 C:\temp\tds 디렉터리에 압축을 푼 것으로 가정.

set INCLUDE=C:\temp\tds\include;%INCLUDE%
set LIB=C:\temp\tds\lib-nossl;C:\temp\tds\lib-nossl\static;%LIB%

이후 컴파일 오류는 없지만 대신 link.exe 단계에서 오류가 발생합니다.

c:\temp> python -m pip install pymssql
Collecting pymssql
  Using cached pymssql-2.2.8.tar.gz (171 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: pymssql
  Building wheel for pymssql (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Python37\python.exe' 'C:\Python37\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel '%USERPROFILE%\AppData\Local\Temp\tmp0ykb3vrw'
       cwd: %USERPROFILE%\AppData\Local\Temp\pip-install-5zn5kp88\pymssql_4ecd3707a9b24eaba3f06dbae1163ed0
  Complete output (44 lines):
  setup.py: platform.system() => Windows
  setup.py: platform.architecture() => ('64bit', 'WindowsPE')
  setup.py: include_dirs => []
  setup.py: library_dirs => []
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-cpython-37
  creating build\lib.win32-cpython-37\pymssql
  copying src\pymssql\__init__.py -> build\lib.win32-cpython-37\pymssql
  running build_ext
  Compiling src\pymssql\_mssql.pyx because it changed.
  [1/1] Cythonizing src\pymssql\_mssql.pyx
  building 'pymssql._mssql' extension
  creating build\temp.win32-cpython-37
  creating build\temp.win32-cpython-37\Release
  creating build\temp.win32-cpython-37\Release\src
  creating build\temp.win32-cpython-37\Release\src\pymssql
  "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Python37\include -IC:\Python37\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" -IC:\temp\tds\include "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcsrc\pymssql\_mssql.c /Fobuild\temp.win32-cpython-37\Release\src\pymssql\_mssql.obj -DMSDBLIB
  _mssql.c
  src\pymssql\_mssql.c(37094): warning C4146: unary minus operator applied to unsigned type, result still unsigned
  src\pymssql\_mssql.c(38018): warning C4146: unary minus operator applied to unsigned type, result still unsigned
  "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\bin\HostX86\x86\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:c:/Program Files/OpenSSL-Win64/lib" /LIBPATH:C:\Python37\libs /LIBPATH:C:\Python37 /LIBPATH:C:\Python37\PCbuild\win32 "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\ATLMFC\lib\x86" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\lib\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x86" /LIBPATH:C:\temp\tds\lib-nossl /LIBPATH:C:\temp\tds\lib-nossl\static "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\ATLMFC\lib\x86" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\lib\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x86" replacements.lib db-lib.lib tds.lib tdsutils.lib ws2_32.lib wsock32.lib kernel32.lib shell32.lib libssl_static.lib libcrypto_static.lib crypt32.lib advapi32.lib gdi32.lib user32.lib /EXPORT:PyInit__mssql build\temp.win32-cpython-37\Release\src\pymssql\_mssql.obj /OUT:build\lib.win32-cpython-37\pymssql\_mssql.cp37-win_amd64.pyd /IMPLIB:build\temp.win32-cpython-37\Release\src\pymssql\_mssql.cp37-win_amd64.lib
  LINK : fatal error LNK1181: cannot open input file 'tdsutils.lib'
  warning: src\pymssql\_mssql.pyx:27:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:28:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:29:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:30:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:31:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:32:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:35:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:36:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:38:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:82:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:230:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:264:4: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:333:4: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:831:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:919:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:1005:12: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:1379:16: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  warning: src\pymssql\_mssql.pyx:1713:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
  error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.36.32532\\bin\\HostX86\\x86\\link.exe' failed with exit code 1181
  ----------------------------------------
  ERROR: Failed building wheel for pymssql
Failed to build pymssql
ERROR: Could not build wheels for pymssql which use PEP 517 and cannot be installed directly

중간에 보면 "LINK : fatal error LNK1181: cannot open input file 'tdsutils.lib'" 오류가 있는데 실제로 "C:\temp\tds" 하위 디렉터리에는 해당 파일이 없습니다.

이에 관해 이슈를 보면,

Error building pymssql on Windows - tdsutils.lib does not exist.
; https://groups.google.com/g/pymssql/c/EVbXwuM0gZk

"Mikhail Terekhov"의 답변에 해당 lib 파일은 직접 빌드해서 얻는 것처럼 나옵니다.




그런데, 이 과정이 좀 복잡합니다. 우선, build.py 파일을 다운로드하고, 실행하면,

c:\temp\tdsutil> python build.py --ws-dir=freetds --dist-dir=dist --sdist --freetds-version="1.3.4"
downloading http://ftp.freetds.org/pub/freetds/stable/freetds-1.3.4.tar.gz to c:\temp\tdsutil\freetds\freetds-1.3.4.tar.gz
downloading DONE
extracting win-iconv.zip -> c:\temp\tdsutil\freetds\win-iconv
running cmake in c:\temp\tdsutil\freetds\win-iconv
The system cannot find the path specified.
Build failed: Command '"C:\Program Files\CMake\bin\cmake.exe" -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC=on -DBUILD_SHARED=off -DBUILD_EXECUTABLE=off -DBUILD_TEST=off .' returned non-zero exit status 1.

CMake 환경을 먼저 구성해야 합니다. ^^; 제 경우에는 Visual Studio 2022의 구성 요소로 "C++ CMake tools for Windows"를 설치해 두었기 때문에 이미 "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake" 경로에 있으므로 juction 연결을 한 다음,

mklink /J "C:\Program Files\CMake" "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake"

다시 실행합니다.

c:\temp\tdsutil> python build.py --ws-dir=freetds --dist-dir=dist --sdist --freetds-version="1.3.4"
c:\temp\tdsutil\freetds\freetds-1.3.4.tar.gz already exists
c:\temp\tdsutil\freetds\win-iconv.zip already exists
downloading DONE
extracting win-iconv.zip -> c:\temp\tdsutil\freetds\win-iconv
running cmake in c:\temp\tdsutil\freetds\win-iconv
CMake Warning (dev) at CMakeLists.txt:1 (project):
  cmake_minimum_required() should be called prior to this top-level project()
  call.  Please see the cmake-commands(7) manual for usage documentation of
  both commands.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is MSVC 19.36.32535.0
-- The CXX compiler identification is MSVC 19.36.32535.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
...[생략]...
-- Installing: C:/temp/tdsutil/freetds/freetds-1.3.4-bin/lib/tdsutils.lib
-- Installing: C:/temp/tdsutil/freetds/freetds-1.3.4-bin/lib/replacements.lib
-- Installing: C:/temp/tdsutil/freetds/freetds-1.3.4-bin/lib/tds.lib
...[생략]...
-- Installing: C:/temp/tdsutil/freetds/freetds-1.3.4-bin/lib/tdssrv.lib
-- Installing: C:/temp/tdsutil/freetds/freetds-1.3.4-bin/bin/tdspool.exe
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
Build failed: Command 'C:\Python37\python.exe -m pip wheel . -w c:\temp\tdsutil\dist' returned non-zero exit status 1.

비록 실패는 했지만, tdsutils.lib 파일은 빌드가 되었으므로 그 파일을 "C:\temp\tds\lib-nossl" 디렉터리에 복사 후 다시 실행하면 다른 라이브러리를 찾기 시작합니다.

replacements.lib db-lib.lib tds.lib tdsutils.lib ws2_32.lib wsock32.lib kernel32.lib shell32.lib libssl_static.lib libcrypto_static.lib crypt32.lib advapi32.lib gdi32.lib user32.lib


이것들 중에서 없는 것은 libssl_static.lib, libcrypto_static.lib 2개 파일인데, 다행히 vcpkg로 openssl을 빌드하면 구할 수 있습니다.

그래서 ^^; 다시 빌드해 볼까요?

c:\temp> python -m pip install pymssql
...[생략]...
      src\pymssql\_mssql.c(38018): warning C4146: unary minus operator applied to unsigned type, result still unsigned
      "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:c:/Program Files/OpenSSL-Win64/lib" /LIBPATH:C:\Python37\libs /LIBPATH:C:\Python37 /LIBPATH:C:\Python37\PCbuild\amd64 "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x64" /LIBPATH:C:\temp\tds\lib-nossl /LIBPATH:C:\temp\tds\lib-nossl\static "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x64" replacements.lib db-lib.lib tds.lib tdsutils.lib ws2_32.lib wsock32.lib kernel32.lib shell32.lib libssl_static.lib libcrypto_static.lib crypt32.lib advapi32.lib gdi32.lib user32.lib /EXPORT:PyInit__mssql build\temp.win-amd64-cpython-37\Release\src\pymssql\_mssql.obj /OUT:build\lib.win-amd64-cpython-37\pymssql\_mssql.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-cpython-37\Release\src\pymssql\_mssql.cp37-win_amd64.lib
         Creating library build\temp.win-amd64-cpython-37\Release\src\pymssql\_mssql.cp37-win_amd64.lib and object build\temp.win-amd64-cpython-37\Release\src\pymssql\_mssql.cp37-win_amd64.exp
      tds.lib(iconv.c.obj) : error LNK2001: unresolved external symbol iconv_open
      tds.lib(iconv.c.obj) : error LNK2001: unresolved external symbol iconv_close
      tds.lib(iconv.c.obj) : error LNK2001: unresolved external symbol iconv
      build\lib.win-amd64-cpython-37\pymssql\_mssql.cp37-win_amd64.pyd : fatal error LNK1120: 3 unresolved externals

이번에는 iconv 관련 함수를 못 찾고 있습니다. 이게 약간 문제인데요, 애당초 link.exe 실행 명령을 보면 iconv.lib를 전달하지 않으므로 해당 함수들을 링킹하지 못하고 있는 것입니다. 일단 임시 방편으로 pip install 설치 시 temporary 디렉터리를 삭제하지 않도록 빌드한 다음,

c:\temp> python -m pip install pymssql --no-clean

바로 그 임시 디렉터리를 찾아,

C:\> dir /a/s lib.win-amd64-cpython-37
 Volume in drive C has no label.
 Volume Serial Number is 7090-BBAB

 Directory of %USERPROFILE%\AppData\Local\Temp\pip-install-n3akcnxs\pymssql_e28c63ffe19a49c6ade659e651329395\build

2023-08-10  오전 10:47    <DIR>          lib.win-amd64-cpython-37
               0 File(s)              0 bytes

     Total Files Listed:
               0 File(s)              0 bytes
               1 Dir(s)  317,131,005,952 bytes free

build 디렉터리를 하위로 두는 곳으로 이동해,

cd %USERPROFILE%\AppData\Local\Temp\pip-install-n3akcnxs\pymssql_e28c63ffe19a49c6ade659e651329395

iconv.lib를 담은 명령어를 우리가 직접 실행하는 것도 가능합니다.

"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:c:/Program Files/OpenSSL-Win64/lib" /LIBPATH:C:\Python37\libs /LIBPATH:C:\Python37 /LIBPATH:C:\Python37\PCbuild\amd64 "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x64" /LIBPATH:C:\temp\tds\lib-nossl /LIBPATH:C:\temp\tds\lib-nossl\static "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x64" db-lib.lib tds.lib tdsutils.lib ws2_32.lib wsock32.lib kernel32.lib shell32.lib libssl_static.lib iconv.lib libcrypto_static.lib crypt32.lib advapi32.lib gdi32.lib user32.lib /EXPORT:PyInit__mssql build\temp.win-amd64-cpython-37\Release\src\pymssql\_mssql.obj /OUT:build\lib.win-amd64-cpython-37\pymssql\_mssql.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-cpython-37\Release\src\pymssql\_mssql.cp37-win_amd64.lib


하지만, 그래도 오류가 발생하는데요, ^^;

...[생략]...
Generating code
Finished generating code
replacements.lib(win_mutex.c.obj) : error LNK2005: tds_win_mutex_lock already defined in tdsutils.lib(win_mutex.c.obj)
build\lib.win-amd64-cpython-37\pymssql\_mssql.cp37-win_amd64.pyd : fatal error LNK1169: one or more multiply defined symbols found

이전에 build.py로 빌드했던 tdsutils.lib와 freetds-v0.95.95-win-x86_64-vs2015.zip에 있던 replacements.lib에 동일한 tds_win_mutex_lock 함수가 중복 포함돼 있어 오류가 발생합니다. ^^;

휴... 끝이 없습니다. ^^;




다시 처음으로 돌아가서, "freetds-v0.95.95-win-x86_64-vs2015.zip" 버전 v0.95.95가 2016년 4월 2일 릴리스니까, 아마도 그때 버전의 pymssql은 잘 설치가 되었을 것입니다.

당시 버전을 보면 2.1.2인데요, 이걸로 설치해 보면 오류 메시지가 그래도 나옵니다.

c:\temp> python -m pip install pymssql==2.1.2
    ...[생략]...
      _mssql.c
      _mssql.c(10930): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
      _mssql.c(15967): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
      _mssql.c(24724): warning C4146: unary minus operator applied to unsigned type, result still unsigned
      _mssql.c(25522): error C2039: 'exc_type': is not a member of '_ts'
      C:\Python37\include\pystate.h(212): note: see declaration of '_ts'
      _mssql.c(25523): error C2039: 'exc_value': is not a member of '_ts'
      C:\Python37\include\pystate.h(212): note: see declaration of '_ts'
    ...[생략]...

빌드 과정 중 Python 설치 디렉터리의 include\pystate.h 헤더 파일을 참고하는데, 제가 실습한 Python 3.7에는 _ts 헤더 파일에 exc_type 필드가 실제로 존재하지 않았습니다.

typedef struct _ts {
    /* See Python/ceval.c for comments explaining most fields */

    struct _ts *prev;
    struct _ts *next;
    PyInterpreterState *interp;

    struct _frame *frame;
    ...[생략]...
}

그렇다면 당시 파이썬에는 있었다는 이야기인데요, 단적으로 python 2.7의 헤더를 보면,

typedef struct _ts {
    /* See Python/ceval.c for comments explaining most fields */

    struct _ts *next;
    PyInterpreterState *interp;

    struct _frame *frame;
    int recursion_depth;
    /* 'tracing' keeps track of the execution depth when tracing/profiling.
       This is to prevent the actual trace/profile code from being recorded in
       the trace/profile. */
    int tracing;
    int use_tracing;

    Py_tracefunc c_profilefunc;
    Py_tracefunc c_tracefunc;
    PyObject *c_profileobj;
    PyObject *c_traceobj;

    PyObject *curexc_type;
    PyObject *curexc_value;
    PyObject *curexc_traceback;

    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;

   ...[생략]...
}

이렇게 exc_type 필드가 보입니다. 음... 결국 적절한 파이썬 버전까지 맞춰서 빌드하면 된다는 이야기인데, 나중에 시간나면 해봐야겠습니다. 일단 현재는 여기까지만! ^^;




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







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

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

비밀번호

댓글 작성자
 




... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12219정성태6/1/202011647.NET Framework: 906. C# - lock (this), lock (typeof(...))를 사용하면 안 되는 이유파일 다운로드1
12218정성태5/27/202011608.NET Framework: 905. C# - DirectX 게임 클라이언트 실행 중 키보드 입력을 감지하는 방법 [3]
12217정성태5/24/202010044오류 유형: 615. Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
12216정성태5/15/202013207.NET Framework: 904. USB/IP PROJECT를 이용해 C#으로 USB Keyboard 가상 장치 만들기 [14]파일 다운로드1
12215정성태5/12/202018312개발 환경 구성: 490. C# - (Wireshark의) USBPcap을 이용한 USB 패킷 모니터링 [10]파일 다운로드1
12214정성태5/5/202010569개발 환경 구성: 489. 정식 인증서가 있는 경우 Device Driver 서명하는 방법 (2) - UEFI/SecureBoot [1]
12213정성태5/3/202012246개발 환경 구성: 488. (User-mode 코드로 가상 USB 장치를 만들 수 있는) USB/IP PROJECT 소개
12212정성태5/1/20209866개발 환경 구성: 487. UEFI / Secure Boot 상태인지 확인하는 방법
12211정성태4/27/202012204개발 환경 구성: 486. WSL에서 Makefile로 공개된 리눅스 환경의 C/C++ 소스 코드 빌드
12210정성태4/20/202012643.NET Framework: 903. .NET Framework의 Strong-named 어셈블리 바인딩 (1) - app.config을 이용한 바인딩 리디렉션 [1]파일 다운로드1
12209정성태4/13/202010695오류 유형: 614. 리눅스 환경에서 C/C++ 프로그램이 Segmentation fault 에러가 발생한 경우 (2)
12208정성태4/12/202010131Linux: 29. 리눅스 환경에서 C/C++ 프로그램이 Segmentation fault 에러가 발생한 경우
12207정성태4/2/20209110스크립트: 19. Windows PowerShell의 NonInteractive 모드
12206정성태4/2/202011416오류 유형: 613. 파일 잠금이 바로 안 풀린다면? - The process cannot access the file '...' because it is being used by another process.
12205정성태4/2/20208787스크립트: 18. Powershell에서는 cmd.exe의 명령어를 지원하진 않습니다.
12204정성태4/1/20208612스크립트: 17. Powershell 명령어에 ';' (semi-colon) 문자가 포함된 경우
12203정성태3/18/202010689오류 유형: 612. warning: 'C:\ProgramData/Git/config' has a dubious owner: '...'.
12202정성태3/18/202013249개발 환경 구성: 486. .NET Framework 프로젝트를 위한 GitLab CI/CD Runner 구성
12201정성태3/18/202011073오류 유형: 611. git-credential-manager.exe: Using credentials for username "Personal Access Token". [1]
12200정성태3/18/202011468VS.NET IDE: 145. NuGet + Github 라이브러리 디버깅 관련 옵션 3가지 - "Enable Just My Code" / "Enable Source Link support" / "Suppress JIT optimization on module load (Managed only)"
12199정성태3/17/20209290오류 유형: 610. C# - CodeDomProvider 사용 시 Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path '...\f2_6uod0.tmp'.
12198정성태3/17/202012088오류 유형: 609. SQL 서버 접속 시 "Cannot open user default database. Login failed."
12197정성태3/17/202011232VS.NET IDE: 144. .NET Core 콘솔 응용 프로그램을 배포(publish) 시 docker image 자동 생성 - 두 번째 이야기 [1]
12196정성태3/17/20209128오류 유형: 608. The ServicedComponent being invoked is not correctly configured (Use regsvcs to re-register).
12195정성태3/16/202010882.NET Framework: 902. C# - 프로세스의 모든 핸들을 열람 - 세 번째 이야기
12194정성태3/16/202013174오류 유형: 607. PostgreSQL - Npgsql.NpgsqlException: sorry, too many clients already
... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...