问题描述
尝试导入 pyodbc 时出现以下错误.我该如何解决?我在这里找到的所有其他东西都不起作用.我也试过这个网站上的一切:https://medium.com/@mauridb/how-to-check-your-anaconda-version-c092400c9978 关于更新 anaconda 版本(在这台电脑上只安装了 30 天).
When trying to import pyodbc i get the below error. How do I resolve this? All other things I have found on here has not worked. I have also tried everything on this site: https://medium.com/@mauridb/how-to-check-your-anaconda-version-c092400c9978 when it comes to updating the anaconda version (which has only been installed for 30 days on this computer).
我也尝试了以下代码,但在导入时仍然出现相同的错误.任何帮助都会很棒.
I have also tried the below code, and I still get the same error on import. Any assistance would be great.
pip install pyodbc --force-reinstall
我正在使用:
Python 3.7.4(默认,2019 年 8 月 9 日,18:34:13)[MSC v.1915 64 位 (AMD64)]输入版权"、信用"或许可"以获取更多信息.Windows 10 PC 上来自 Anaconda Navigator 1.9.7 的 Spyder 4.0.1
Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)]Type "copyright", "credits" or "license" for more information.Spyder 4.0.1 from Anaconda Navigator 1.9.7 on a windows 10 PC
import pyodbc ImportError: DLL load failed: The specified module can找不到.
推荐答案
改为使用 pypyodbc 包.连接字符串与pyodbc 相同.调用 SQL 代码:
Using pypyodbc package worked instead. The connection strings are the same as pyodbc. Call the SQL code with:
import pandas as pd
import pypyodbc
conn = pypyodbc.connect('Driver'={SQL Server};'
'Server=Server;'
'Database=database;
'Trusted_Connection=yes;')
pd.read_sql_query('''SQL CODE''', conn)
在等号 (=) 所在的连接字符串中不要使用任何速度非常重要.不知道为什么会这样.
It was very important to not use any pace in the connection string where the equal (=) signs are. Not sure why this is.
这篇关于pyodbc 导入错误:DLL 加载失败:指定的模块可以 >找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!