簡體   English   中英

當我嘗試在 cmd 中使用 pip 安裝 pyodbc 時,如何解決錯誤上升

[英]How do I solve an error rising when I try installing pyodbc using pip in cmd

當我嘗試使用cmdWindows計算機上安裝pyodbc時出現錯誤。

C:\Users\Pcyber\AppData\Local\Programs\Python\Python310>python.exe -m pip install pyodbc
Collecting pyodbc
  Using cached pyodbc-4.0.32.tar.gz (280 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for pyodbc, since package 'wheel' is not installed.
Installing collected packages: pyodbc
    Running setup.py install for pyodbc ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Pcyber\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Pcyber\\AppData\\Local\\Temp\\pip-install-w2t0bax7\\pyodbc_0972efc851a7442b9e86edce259cfc8a\\setup.py'"'"'; __file__='"'"'C:\\Users\\Pcyber\\AppData\\Local\\Temp\\pip-install-w2t0bax7\\pyodbc_0972efc851a7442b9e86edce259cfc8a\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Pcyber\AppData\Local\Temp\pip-record-xbgtptdk\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Pcyber\AppData\Local\Programs\Python\Python310\Include\pyodbc'
         cwd: C:\Users\Pcyber\AppData\Local\Temp\pip-install-w2t0bax7\pyodbc_0972efc851a7442b9e86edce259cfc8a\
    Complete output (5 lines):
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Pcyber\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Pcyber\\AppData\\Local\\Temp\\pip-install-w2t0bax7\\pyodbc_0972efc851a7442b9e86edce259cfc8a\\setup.py'"'"'; __file__='"'"'C:\\Users\\Pcyber\\AppData\\Local\\Temp\\pip-install-w2t0bax7\\pyodbc_0972efc851a7442b9e86edce259cfc8a\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Pcyber\AppData\Local\Temp\pip-record-xbgtptdk\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Pcyber\AppData\Local\Programs\Python\Python310\Include\pyodbc' Check the logs for full command output.

根據錯誤消息的那部分:

extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

您的平台上似乎缺少合適的 C++ 編譯器。 根據 pyodbc 的文檔,您需要一個:

請注意,pyodbc 包含 C++ 擴展,因此您需要在計算機上安裝合適的 C++ 編譯器來為所有操作系統安裝 pyodbc。

見這里: https://pypi.org/project/pyodbc/

我建議使用錯誤消息中建議的一種形式的 Microsoft Build Tools。

pip正在嘗試從源代碼編譯pyodbc ,但您的計算機上沒有安裝任何編譯器。 通常有不需要編譯的二進制包,但您的 python 版本(3.10)沒有。

您應該降級到舊版本的 python(例如 3.9)或按照錯誤給出的說明安裝 Microsoft Visual C++ 編譯器。

我已經卸載了從 python3.10 升級到 python3.9.5 的 python,現在我可以毫無挑戰地使用 pip。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM