Visual Studio 14 的离线安装程序,用于 pyodbc 包/离线 pyodbc 安装

Offline Installer for Visual Studio 14 for pyodbc package / offline pyodbc installation

我在没有互联网连接的 windows 服务器上安装了 python。

现在我想通过 python 连接到服务器上的 SQL 服务器数据库,因此想安装 PyODBC。 我通过互联网连接从本地 windows 从他们的网站下载了 pyodbc-4.0.17.tar.gz,上传到服务器并尝试通过 pip install 通过命令行安装它,但收到以下错误消息:

  ERROR: Command errored out with exit status 1:
     command: 'c:\users\a2289770-3\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tok
enize; sys.argv[0] = '"'"'C:\Users\A22897~1\AppData\Local\Temp\3\pip-req-build-agil8hty\setup.py'"'"'; __file__=
'"'"'C:\Users\A22897~1\AppData\Local\Temp\3\pip-req-build-agil8hty\setup.py'"'"';f=getattr(tokenize, '"'"'open'"
'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exe
c'"'"'))' install --record 'C:\Users\A22897~1\AppData\Local\Temp\pip-record-hfui07d3\install-record.txt' --single-vers
ion-externally-managed --compile --install-headers 'c:\users\a2289770-3\appdata\local\programs\python\python37\Include\p
yodbc'
         cwd: C:\Users\A22897~1\AppData\Local\Temp\pip-req-build-agil8hty\
    Complete output (5 lines):
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.micr
osoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\a2289770-3\appdata\local\programs\python\python37\python.exe' -
u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\A22897~1\AppData\Local\Temp\3\pip-req-build-a
gil8hty\setup.py'"'"'; __file__='"'"'C:\Users\A22897~1\AppData\Local\Temp\3\pip-req-build-agil8hty\setup.py'"'"
';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec
(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\A22897~1\AppData\Local\Temp\pip-record-hfui07d3\
install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\a2289770-3\appdata\local\p
rograms\python\python37\Include\pyodbc' Check the logs for full command output.

所以我尝试安装 Visual C++ 14,但我尝试的所有安装包都尝试连接到 Internet,因此在安装过程中停止。

有人可以帮忙吗?

好的,我在这里找到了解决方案:How to install packages offline?

  • 正在创建 requirements.txt,包括通过 pip freeze > requirements.txt

    包含所有需要的包
  • 通过互联网连接将所有包及其依赖项下载到本地 windows 上的目录中 - 还包括 requirements.txt 那里(在我的例子中是“wheelhouse”,通过 pip download,详见link)

  • 将该目录上传到服务器

  • 使用以下命令安装

    pip install -r wheelhouse/requirements.txt --no-index --find-links wheelhouse

现在我可以在离线服务器上使用pyodbc了。

我觉得很奇怪,它以前需要 Microsoft Visual C++ 14.0 并且现在可以在我没有安装它的情况下工作,但是无论如何...如果有人知道这样做的原因,我有兴趣在评论中阅读它。