初学者:Python can';找不到';pyodbc';包裹
我对Python语言非常陌生,有一个小程序。它一直在工作,但有些变化,现在我无法让它运行。查找“pyodbc”时遇到问题。我安装了“pyodbc”包,所以我不明白为什么会出现错误。我正在使用Python 3.7.6。谢谢你的帮助 pip安装pyodbc初学者:Python can';找不到';pyodbc';包裹,python,python-3.x,pip,Python,Python 3.x,Pip,我对Python语言非常陌生,有一个小程序。它一直在工作,但有些变化,现在我无法让它运行。查找“pyodbc”时遇到问题。我安装了“pyodbc”包,所以我不明白为什么会出现错误。我正在使用Python 3.7.6。谢谢你的帮助 pip安装pyodbc WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see https://githu
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Requirement already satisfied: pyodbc in c:\users\c113850\appdata\roaming\python\python37\site-packages (4.0.28)
代码:
import requests
import pyodbc
from bs4 import BeautifulSoup
from datetime import datetime
import pytz
import time
import azure.functions
page = requests.get("https://samplepage.html")
if page.status_code == 200:
print(page.status_code)
#print(page.content)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.title)
rows = soup.find_all('tr')
# for row in rows: # Print all occurrences
# print(row.get_text())
print(rows[0])
print(rows[7])
pjmtime = rows[0].td.get_text()
print("PJM = ",pjmtime)
#dt_string = "Tue Jan 21 18:00:00 EST 2020"
dt_object = datetime.strptime(pjmtime, "%a %b %d %H:%M:%S EST %Y")
print("Timestamp =", dt_object)
eastern=pytz.timezone('US/Eastern')
date_eastern=eastern.localize(dt_object,is_dst=None)
date_utc=date_eastern.astimezone(pytz.utc)
print("UTC =", date_utc)
row = soup.find(text='PRICE').parent.parent
name = row.select('td')[0].get_text()
typed = row.select('td')[1].get_text()
weighted = row.select('td')[2].get_text()
hourly = row.select('td')[3].get_text()
server = 'db.database.windows.net'
database = '...'
username = '...'
password = '...'
driver = '{ODBC Driver 17 for SQL Server}'
cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()
print("insert into [PJMLocationalMarginalPrice] ([Name],[Type],[WeightedAverage],[HourlyIntegrated],[TimeStamp]) values(?,?,?,?,?)",
(name,typed,weighted,hourly,date_utc))
cursor.execute("insert into [PJMLocationalMarginalPrice] ([Name],[Type],[WeightedAverage],[HourlyIntegrated],[TimeStamp]) values (?,?,?,?,?)",
(name,typed,weighted,hourly,date_utc))
cnxn.commit()
else:
print("Error: page not open")
Traceback (most recent call last):
File "c:/Users/C113850/PycharmProjects/Scraping101/Scraping.py", line 2, in <module>
import pyodbc
ImportError: DLL load failed: The specified module could not be found.
错误:
import requests
import pyodbc
from bs4 import BeautifulSoup
from datetime import datetime
import pytz
import time
import azure.functions
page = requests.get("https://samplepage.html")
if page.status_code == 200:
print(page.status_code)
#print(page.content)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.title)
rows = soup.find_all('tr')
# for row in rows: # Print all occurrences
# print(row.get_text())
print(rows[0])
print(rows[7])
pjmtime = rows[0].td.get_text()
print("PJM = ",pjmtime)
#dt_string = "Tue Jan 21 18:00:00 EST 2020"
dt_object = datetime.strptime(pjmtime, "%a %b %d %H:%M:%S EST %Y")
print("Timestamp =", dt_object)
eastern=pytz.timezone('US/Eastern')
date_eastern=eastern.localize(dt_object,is_dst=None)
date_utc=date_eastern.astimezone(pytz.utc)
print("UTC =", date_utc)
row = soup.find(text='PRICE').parent.parent
name = row.select('td')[0].get_text()
typed = row.select('td')[1].get_text()
weighted = row.select('td')[2].get_text()
hourly = row.select('td')[3].get_text()
server = 'db.database.windows.net'
database = '...'
username = '...'
password = '...'
driver = '{ODBC Driver 17 for SQL Server}'
cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()
print("insert into [PJMLocationalMarginalPrice] ([Name],[Type],[WeightedAverage],[HourlyIntegrated],[TimeStamp]) values(?,?,?,?,?)",
(name,typed,weighted,hourly,date_utc))
cursor.execute("insert into [PJMLocationalMarginalPrice] ([Name],[Type],[WeightedAverage],[HourlyIntegrated],[TimeStamp]) values (?,?,?,?,?)",
(name,typed,weighted,hourly,date_utc))
cnxn.commit()
else:
print("Error: page not open")
Traceback (most recent call last):
File "c:/Users/C113850/PycharmProjects/Scraping101/Scraping.py", line 2, in <module>
import pyodbc
ImportError: DLL load failed: The specified module could not be found.
回溯(最近一次呼叫最后一次):
文件“c:/Users/C113850/PycharmProjects/Scraping101/Scraping.py”,第2行,在
导入pyodbc
ImportError:DLL加载失败:找不到指定的模块。
更新:
我在查看站点包下的文件夹时,注意到“pyodbc”文件夹不在那里,但“pyodbc-4.0.28.dist info”文件夹在那里。
模块安装不正确 请尝试重新安装:
pip uninstall pyodbc
pip install pyodbc
如果不起作用,请尝试使用pip3:
pip uninstall pyodbc
pip3 install pyodbc
模块安装不正确 请尝试重新安装:
pip uninstall pyodbc
pip install pyodbc
如果不起作用,请尝试使用pip3:
pip uninstall pyodbc
pip3 install pyodbc
安装“pyodbc”时是否有活动的Python环境。如果是这样,您将希望在运行脚本之前激活环境,因为您无法访问该环境之外的包 如果没有,您可能只需要卸载并重新安装
pip uninstall pyodbc
pip install pyodbc
安装“pyodbc”时是否有活动的Python环境。如果是这样,您将希望在运行脚本之前激活环境,因为您无法访问该环境之外的包 如果没有,您可能只需要卸载并重新安装
pip uninstall pyodbc
pip install pyodbc
我在Github上发现pyodbc版本4.0.28中有一个bug,因此我将其降级到4.0.27,从而解决了我的问题。更多信息,.我在Github上发现pyodbc版本4.0.28中有一个bug,所以我降级到4.0.27,解决了我的问题。欲了解更多信息,.可能是一个问题。你能检查一下你的终端安装了什么MVC++吗?我不确定MVC++是什么。对不起,我刚才也被我链接的线程缠住了<代码> MVC++<代码> = =代码>微软VisualC++ + ReDIST包<代码>可能是个问题。你能检查一下你的终端安装了什么MVC++吗?我不确定MVC++是什么。对不起,我刚才也被我链接的线程缠住了<代码> MVC++<代码> = =代码>微软VisualC++ + ReDIST包<代码>我尝试安装/重新安装,并获得相同的错误。不确定“主动”环境的目的。然而,我回到了我在互联网上遵循的说明,激活了venu并卸载/重新安装了我的所有软件包,现在我在“请求”上发现了错误。但我注意到的是一些安装在我的用户帐户“c:\users\c113850\appdata\roaming\python…”下的软件包,以及其他安装在“c:\program files\python37\lib\site packages\…”下的软件包。我尝试取消安装/重新安装,但遇到了相同的错误。不确定“主动”环境的目的。然而,我回到了我在互联网上遵循的说明,激活了venu并卸载/重新安装了我的所有软件包,现在我在“请求”上发现了错误。但我注意到的是一些安装在我的用户帐户“c:\users\c113850\appdata\roaming\python…”下的软件包,以及其他安装在“c:\program files\python37\lib\site packages\…”下的软件包