Microsoft MVP성태의 닷넷 이야기
오류 유형: 874. 파이썬 - pymssql을 윈도우 환경에서 설치 불가 [링크 복사], [링크+제목 복사],
조회: 3535
글쓴 사람
정성태 (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

비밀번호

댓글 작성자
 




... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
12731정성태7/23/20217587개발 환경 구성: 584. Add Internal URLs 화면에서 "Save" 버튼이 비활성화 된 경우
12730정성태7/23/20219083개발 환경 구성: 583. Visual Studio Code - Go 코드에서 입력을 받는 경우
12729정성태7/22/20218031.NET Framework: 1080. xUnit 단위 테스트에 메서드/클래스 수준의 문맥 제공 - Fixture
12728정성태7/22/20217519.NET Framework: 1079. MSTestv2 단위 테스트에 메서드/클래스/어셈블리 수준의 문맥 제공
12727정성태7/21/20218476.NET Framework: 1078. C# 단위 테스트 - MSTestv2/NUnit의 Assert.Inconclusive 사용법(?) [1]
12726정성태7/21/20218306VS.NET IDE: 169. 비주얼 스튜디오 - 단위 테스트 선택 시 MSTestv2 외의 xUnit, NUnit 사용법 [1]
12725정성태7/21/20217029오류 유형: 741. Failed to find the "go" binary in either GOROOT() or PATH
12724정성태7/21/20219719개발 환경 구성: 582. 윈도우 환경에서 Visual Studio Code + Go (Zip) 개발 환경 [1]
12723정성태7/21/20217342오류 유형: 740. SharePoint - Alternate access mappings have not been configured 경고
12722정성태7/20/20217205오류 유형: 739. MSVCR110.dll이 없어 exe 실행이 안 되는 경우
12721정성태7/20/20217866오류 유형: 738. The trust relationship between this workstation and the primary domain failed. - 세 번째 이야기
12720정성태7/19/20217196Linux: 43. .NET Core/5+ 응용 프로그램의 Ubuntu (Debian) 패키지 준비
12719정성태7/19/20216344오류 유형: 737. SharePoint 설치 시 "0x800710D8 The object identifier does not represent a valid object." 오류 발생
12718정성태7/19/20216921개발 환경 구성: 581. Windows에서 WSL로 파일 복사 시 root 소유권으로 적용되는 문제파일 다운로드1
12717정성태7/18/20216878Windows: 195. robocopy에서 파일의 ADS(Alternate Data Stream) 정보 복사를 제외하는 방법
12716정성태7/17/20217716개발 환경 구성: 580. msbuild의 Exec Task에 robocopy를 사용하는 방법파일 다운로드1
12715정성태7/17/20219392오류 유형: 736. Windows - MySQL zip 파일 버전의 "mysqld --skip-grant-tables" 실행 시 비정상 종료 [1]
12714정성태7/16/20218172오류 유형: 735. VCRUNTIME140.dll, MSVCP140.dll, VCRUNTIME140.dll, VCRUNTIME140_1.dll이 없어 exe 실행이 안 되는 경우
12713정성태7/16/20218717.NET Framework: 1077. C# - 동기 방식이면서 비동기 규약을 따르게 만드는 Task.FromResult파일 다운로드1
12712정성태7/15/20218119개발 환경 구성: 579. Azure - 리눅스 호스팅의 Site Extension 제작 방법
12711정성태7/15/20218453개발 환경 구성: 578. Azure - Java Web App Service를 위한 Site Extension 제작 방법
12710정성태7/15/202110262개발 환경 구성: 577. MQTT - emqx.io 서비스 소개
12709정성태7/14/20216886Linux: 42. 실행 중인 docker 컨테이너에 대한 구동 시점의 docker run 명령어를 확인하는 방법
12708정성태7/14/202110279Linux: 41. 리눅스 환경에서 디스크 용량 부족 시 원인 분석 방법
12707정성태7/14/202177509오류 유형: 734. MySQL - Authentication method 'caching_sha2_password' not supported by any of the available plugins.
12706정성태7/14/20218729.NET Framework: 1076. C# - AsyncLocal 기능을 CallContext만으로 구현하는 방법 [2]파일 다운로드1
... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...