Microsoft MVP성태의 닷넷 이야기
오류 유형: 874. 파이썬 - pymssql을 윈도우 환경에서 설치 불가 [링크 복사], [링크+제목 복사],
조회: 3512
글쓴 사람
정성태 (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)
12780정성태8/13/20217115.NET Framework: 1088. C# - 버스 노선 및 위치 정보 조회 API 사용을 위한 기초 라이브러리 [2]
12779정성태8/13/20218977개발 환경 구성: 596. 공공 데이터 포털에서 버스 노선 및 위치 정보 조회 API 사용법
12778정성태8/12/20216250오류 유형: 755. PyCharm - "Manage Repositories"의 목록이 나오지 않는 문제
12777정성태8/12/20217891오류 유형: 754. Visual Studio - Input or output cannot be redirected because the specified file is invalid.
12776정성태8/12/20217207오류 유형: 753. gunicorn과 uwsgi 함께 사용 시 ERR_CONNECTION_REFUSED
12775정성태8/12/202117703스크립트: 22. 파이썬 - 윈도우 환경에서 개발한 Django 앱을 WSL 환경의 gunicorn을 이용해 실행
12774정성태8/11/20218810.NET Framework: 1087. C# - Collection 개체의 다중 스레드 접근 시 "Operations that change non-concurrent collections must have exclusive access" 예외 발생
12773정성태8/11/20217977개발 환경 구성: 595. PyCharm - WSL과 연동해 Django App을 윈도우에서 리눅스 대상으로 개발
12772정성태8/11/20219487스크립트: 21. 파이썬 - 윈도우 환경에서 개발한 Django 앱을 WSL 환경의 uwsgi를 이용해 실행 [1]
12771정성태8/11/20217906Windows: 196. "Microsoft Windows Subsystem for Linux Background Host" / "Vmmem"을 종료하는 방법
12770정성태8/11/20218582.NET Framework: 1086. C# - Windows Forms 응용 프로그램의 자식 컨트롤 부하파일 다운로드1
12769정성태8/11/20216544오류 유형: 752. Python - ImportError: No module named pip._internal.cli.main 두 번째 이야기
12768정성태8/10/20217592.NET Framework: 1085. .NET 6에 포함된 신규 BCL API [1]파일 다운로드1
12767정성태8/10/20218682오류 유형: 752. Python - ImportError: No module named pip._internal.cli.main
12766정성태8/9/20217179Java: 32. closing inbound before receiving peer's close_notify
12765정성태8/9/20216518Java: 31. Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
12764정성태8/9/202144952Java: 30. XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid
12763정성태8/9/20217971Java: 29. java.lang.NullPointerException - com.mysql.jdbc.ConnectionImpl.getServerCharset
12762정성태8/8/202111517Java: 28. IntelliJ - Unable to open debugger port 오류
12761정성태8/8/20218700Java: 27. IntelliJ - java: package javax.inject does not exist [2]
12760정성태8/8/20216106개발 환경 구성: 594. 전용 "Command Prompt for ..." 단축 아이콘 만들기
12759정성태8/8/20219231Java: 26. IntelliJ + Spring Framework + 새로운 Controller 추가 [2]파일 다운로드1
12758정성태8/7/20218595오류 유형: 751. Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
12757정성태8/7/20219270Java: 25. IntelliJ + Spring Framework 프로젝트 생성
12756정성태8/6/20218070.NET Framework: 1084. C# - .NET Core Web API 단위 테스트 방법 [1]파일 다운로드1
12755정성태8/5/20217178개발 환경 구성: 593. MSTest - 단위 테스트에 static/instance 유형의 private 멤버 접근 방법파일 다운로드1
... 31  32  33  [34]  35  36  37  38  39  40  41  42  43  44  45  ...