用于pyodbc软件包的Visual Studio 14脱机安装程序/脱机pyodbc安装

问题描述

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

现在,我想通过python连接到服务器上的sql Server数据库,因此想安装PyODBC。 我从具有互联网连接的本地窗口从他们的网站下载了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\3\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\3\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,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'"'"','"'"'\n'"'"');f.close();exec
(compile(code,'"'"'exec'"'"'))' install --record 'C:\Users\A22897~1\AppData\Local\Temp\3\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?

  • 通过所有pip freeze > requirements.txt

    来创建requirements.txt,包括所有需要的软件包
  • 将所有程序包及其依赖项下载到具有Internet连接的本地Windows上的目录中-那里也包括requirements.txt(在我的情况下,通过pip download为“ wheelhouse”,详情请参见链接)

  • 将该目录上传到服务器上

  • 使用以下命令安装

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

现在我可以在脱机服务器上使用pyodbc。

我觉得很奇怪,它以前需要Microsoft Visual C ++ 14.0,现在可以在没有我安装它的情况下运行,但是无论如何...如果有人知道其原因,我将有兴趣在注释中阅读它。