我正在運行 Kali Linux 并嘗試安裝 pyodbc。我正在做 pip install pyodbc 并得到一個很長的錯誤串列,最后我試圖從 Kali linux 中的 vscode 終端安裝 pyodbc,它得到了錯誤。我還安裝了 python3 和 python2 并且還在系統中設定了環境變數并更新了 pip 版本。
pip install pyodbc
Defaulting to user installation because normal site-packages is not writeable
Collecting pyodbc
Using cached pyodbc-4.0.32.tar.gz (280 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyodbc
Building wheel for pyodbc (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [14 lines of output]
running bdist_wheel
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=4.0.32 -I/usr/include/python3.10 -c src/buffer.cpp -o build/temp.linux-x86_64-3.10/src/buffer.o -Wno-write-strings
In file included from src/buffer.cpp:12:
src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
56 | #include <sql.h>
| ^~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyodbc
Running setup.py clean for pyodbc
Failed to build pyodbc
Installing collected packages: pyodbc
Running setup.py install for pyodbc ... error
error: subprocess-exited-with-error
× Running setup.py install for pyodbc did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running install
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=4.0.32 -I/usr/include/python3.10 -c src/buffer.cpp -o build/temp.linux-x86_64-3.10/src/buffer.o -Wno-write-strings
In file included from src/buffer.cpp:12:
src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
56 | #include <sql.h>
| ^~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> pyodbc
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.```
uj5u.com熱心網友回復:
這似乎是 pyodbc 的一個已知問題。在 github 問題中,作者說“您的機器上沒有所需的 ODBC 頭檔案”。
對于 Ubuntu,他建議sudo apt install unixodbc-dev,我認為這也適用于 Kali Linux。
uj5u.com熱心網友回復:
可能是因為您安裝了多個版本的 python 解釋器,正如您自己所說的那樣,并且 pip 不知道要安裝到哪個 python 解釋器。嘗試這個:
python3 -m pip install
或者
python -m pip install
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/495812.html
