Microsoft MVP성태의 닷넷 이야기
오류 유형: 874. 파이썬 - pymssql을 윈도우 환경에서 설치 불가 [링크 복사], [링크+제목 복사],
조회: 3505
글쓴 사람
정성태 (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)
12655정성태6/1/20217715오류 유형: 722. windbg/sos - savemodule - Fail to read memory
12654정성태5/31/20217739오류 유형: 721. Hyper-V - Saved 상태의 VM을 시작 시 오류 발생
12653정성태5/31/202110409.NET Framework: 1060. 닷넷 GC에 새롭게 구현되는 DPAD(Dynamic Promotion And Demotion for GC)
12652정성태5/31/20218507VS.NET IDE: 164. Visual Studio - Web Deploy로 Publish 시 암호창이 매번 뜨는 문제
12651정성태5/31/20218722오류 유형: 720. PostgreSQL - ERROR: 22P02: malformed array literal: "..."
12650정성태5/17/20218041기타: 82. OpenTabletDriver의 버튼에 더블 클릭을 매핑 및 게임에서의 지원 방법
12649정성태5/16/20219397.NET Framework: 1059. 세대 별 GC(Garbage Collection) 방식에서 Card table의 사용 의미 [1]
12648정성태5/16/20218021사물인터넷: 66. PC -> FTDI -> NodeMCU v1 ESP8266 기기를 UART 핀을 연결해 직렬 통신하는 방법파일 다운로드1
12647정성태5/15/20219295.NET Framework: 1058. C# - C++과의 연동을 위한 구조체의 fixed 배열 필드 사용파일 다운로드1
12646정성태5/15/20218414사물인터넷: 65. C# - Arduino IDE의 Serial Monitor 기능 구현파일 다운로드1
12645정성태5/14/20218106사물인터넷: 64. NodeMCU v1 ESP8266 - LittleFS를 이용한 와이파이 접속 정보 업데이트파일 다운로드1
12644정성태5/14/20219237오류 유형: 719. 윈도우 - 제어판의 "프로그램 및 기능" / "Windows 기능 켜기/끄기" 오류 0x800736B3
12643정성태5/14/20218432오류 유형: 718. 서버 유형의 COM+ 사용 시 0x80080005(Server execution failed) 오류 발생
12642정성태5/14/20219361오류 유형: 717. The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
12641정성태5/13/20219052디버깅 기술: 179. 윈도우용 .NET Core 3 이상에서 Windbg의 sos 사용법
12640정성태5/13/202112016오류 유형: 716. RDP 연결 - Because of a protocol error (code: 0x112f), the remote session will be disconnected. [1]
12639정성태5/12/20218875오류 유형: 715. Arduino: Open Serial Monitor - The module '...\detection.node' was compiled against a different Node.js version using NODE_MODULE_VERSION
12638정성태5/12/20219804사물인터넷: 63. NodeMCU v1 ESP8266 - 펌웨어 내 파일 시스템(SPIFFS, LittleFS) 및 EEPROM 활용
12637정성태5/10/20219434사물인터넷: 62. NodeMCU v1 ESP8266 보드의 A0 핀에 다중 아날로그 센서 연결 [1]
12636정성태5/10/20219659사물인터넷: 61. NodeMCU v1 ESP8266 보드의 A0 핀 사용법 - FSR-402 아날로그 압력 센서 연동파일 다운로드1
12635정성태5/9/20218969기타: 81. OpenTabletDriver를 (관리자 권한으로 실행하지 않고도) 관리자 권한의 프로그램에서 동작하게 만드는 방법
12634정성태5/9/20218018개발 환경 구성: 572. .NET에서의 신뢰도 등급 조정 - 외부 Manifest 파일을 두는 방법파일 다운로드1
12633정성태5/7/20219501개발 환경 구성: 571. UAC - 관리자 권한 없이 UIPI 제약을 없애는 방법
12632정성태5/7/20219683기타: 80. (WACOM도 지원하는) Tablet 공통 디바이스 드라이버 - OpenTabletDriver
12631정성태5/5/20219603사물인터넷: 60. ThingSpeak 사물인터넷 플랫폼에 ESP8266 NodeMCU v1 + 조도 센서 장비 연동파일 다운로드1
12630정성태5/5/20219919사물인터넷: 59. NodeMCU v1 ESP8266 보드의 A0 핀 사용법 - CdS Cell(GL3526) 조도 센서 연동파일 다운로드1
... 31  32  33  34  35  36  37  38  [39]  40  41  42  43  44  45  ...