问题描述
我正在尝试使用此处的示例代码:
I'm trying to use the example code from here:
http://www.pymssql.org/en/latest/pymssql_examples.html
我使用 pip
安装了 pymmsql 模块.我也在site-packages文件夹中看到了
I installed the pymmsql module using pip
. I also see it in the site-packages folder
C:\Python27\Lib\site-packages\pymmsql.pyd
但是,当我执行代码时,出现以下错误:
But, when I execute the code, I get the following error:
Traceback (most recent call last):
File "C:\Android\android_workspace\pythonProject\test.py", line 2, in <module>
import pymssql
ImportError: DLL load failed: The specified module could not be found.
我错过了什么?
推荐答案
更新
由于用户社区对 2.1.2 更改的负面反馈,pymssql 2.1.3 及更高版本已恢复让 pip install pymssql
分发静态链接到 FreeTDS 的预编译轮文件不支持 SSL.
Due to negative feedback from the user community regarding the 2.1.2 change, pymssql 2.1.3 and later have reverted to having pip install pymssql
distribute pre-compiled wheel files that are statically linked to FreeTDS without SSL support.
因此,如果您需要 SSL 支持,那么您仍然不能简单地执行 pip install pymssql
.对于 Windows,您需要遵循以下过程,或者对于 Linux,您需要使用类似于 这个问题
Therefore if you need SSL support then you still cannot simply do pip install pymssql
. For Windows you'll need to follow the procedure below, or for Linux you'll need to build pymssql (and possibly FreeTDS) from source using a procedure like the one described in the answers to this question
pymssql 2.1.2 版对其在 Windows 上的设置方式进行了重大更改.以前的版本与 FreeTDS 静态链接一起分发,所以我们需要做的就是安装 pymssql(例如,pip install pymssql
)并且它正常工作",但 SSL 连接不是支持.
Version 2.1.2 of pymssql introduced a significant change in the way it needs to be set up on Windows. Previous versions were distributed with FreeTDS statically linked so all we needed to do was install pymssql (e.g., pip install pymssql
) and it "just worked", but SSL connections were not supported.
从 pymssql 2.1.2 版开始,pymssql 与 Windows 上的 FreeTDS 动态链接,并且不附带 FreeTDS(和 OpenSSL,如果需要)所需的组件.我们仍然可以使用 pip install pymssql
安装 pymssql 本身,但这可能已经不够了.如果我们还没有在 Windows 机器上安装可用的 FreeTDS,那么我们必须自己下载组件.
Beginning with pymssql version 2.1.2, pymssql is dynamically linked with FreeTDS on Windows and does not ship with the required components of FreeTDS (and OpenSSL, if required). We can still install pymssql itself using pip install pymssql
, but that may no longer be sufficient. If we don't already have a working installation of FreeTDS on the Windows machine then we have to download the components ourselves.
可以在此处的 pymssql 文档页面上找到下载链接:
The download links can be found on the pymssql documentation page here:
pymssql - 文档 - FreeTDS - 安装 - Windows.
如果不需要 SSL 连接,那么我们只需要下载 FreeTDS 组件并确保可以通过搜索 Windows PATH 找到lib-nossl"文件夹的内容代码>.
If an SSL connection is not required then we just have to download the FreeTDS components and ensure that the contents of the "lib-nossl" folder can be found by searching the Windows PATH
.
如果需要 SSL 连接,那么我们必须下载 FreeTDS 和 OpenSSL 组件并确保适当的 DLL(在 FreeTDS 的lib"文件夹中,在bin"或可以通过搜索 Windows PATH
来找到 OpenSSL 的bin64"文件夹.
If an SSL connection is required then we have to download both the FreeTDS and OpenSSL components and ensure that the appropriate DLLs (in the "lib" folder for FreeTDS, and in the "bin" or "bin64" folder for OpenSSL) can be located by searching the Windows PATH
.
请注意,这些更改会影响 pymssql 的新安装和升级.据报道,简单地将 pymssql 从 2.1.1 版升级到 2.1.2 版会破坏 Windows 上的 pymssql,直到下载 FreeTDS(和 OpenSSL,如果需要)所需的组件.
Note that these changes affect both new installs and upgrades of pymssql. It has been reported that simply upgrading pymssql from version 2.1.1 to version 2.1.2 will break pymssql on Windows until the required components of FreeTDS (and OpenSSL, if required) are downloaded.
这篇关于“导入错误:DLL 加载失败";尝试在 Windows 上导入 pymssql 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!