问题
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
I am using:
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 could not be found.
回答1:
I had the same problem and work to me when I installed the latest supported Visual C++. You can do a download in link bellow: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
I found this solution from the link bellow, where other people had the problem too. https://github.com/mkleehammer/pyodbc/issues/663
回答2:
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.
来源:https://stackoverflow.com/questions/59687910/pyodbc-importerror-dll-load-failed-the-specified-module-could-not-be-found