Microsoft Visual C++…(&Q)尝试在Windows上安装pyodbc时需要"错误

2022-04-25 00:00:00 python python-3.x windows pip pyodbc

问题描述

我正在尝试安装pyodbc,但出现以下错误。

C:PythonPython37Scripts>pip3 install pyodbc

输出

Collecting pyodbc
  Using cached https://files.pythonhosted.org/packages/aa/71/cef225c4889620a1a00251d24c1746fe0cf4124290a75d1c2dc5c187b61f/pyodbc-4.0.23.tar.gz
Installing collected packages: pyodbc
  Running setup.py install for pyodbc ... error
    Complete output from command c:pythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\Alankar\AppData\Local\Temp\pip-install-7qf14pkz\pyodbc\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersAlankarAppDataLocalTemppip-record-k11gmg0xinstall-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Command "c:pythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\Alankar\AppData\Local\Temp\pip-install-7qf14pkz\pyodbc\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersAlankarAppDataLocalTemppip-record-k11gmg0xinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersAlankarAppDataLocalTemppip-install-7qf14pkzpyodbc

解决方案

我无法使C++生成工具方法工作,但我发现此方法非常简单:

  1. 根据您的计算机架构和版本下载相应的pyodbc车轮(预编译二进制文件):https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyodbc
  2. 运行pip install <wheel path>

例如:

pip install c:usersobdownloadspyodbc-4.0.27-cp38-cp38-win_amd64.whl

相关文章