Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

python - "ImportError: DLL load failed" when trying to import pymssql on Windows

I'm trying to use the example code from here:

http://www.pymssql.org/en/latest/pymssql_examples.html

I installed the pymmsql module using pip. I also see it in the site-packages folder

C:Python27Libsite-packagespymmsql.pyd

But, when I execute the code, I get the following error:

Traceback (most recent call last):
File "C:Androidandroid_workspacepythonProjectest.py", line 2, in <module>
import pymssql
ImportError: DLL load failed: The specified module could not be found.

What am I missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Update

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.

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


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.

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.

The download links can be found on the pymssql documentation page here:

pymssql - Docs - FreeTDS - Installation - Windows.

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.

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...