这个问题发生在我试图进口熊猫时: df = pd.read_html('https://www.macrotrends.net/stocks/charts/BMO/Bank-of-Montreal/dividend-yield-history')
我收到了错误消息:引发ImportError("lxml未找到,请安装它“)
ImportError: lxml not found, please install it
所以我要安装lxml,同样的错误。然后我pip3 lxml,同样的问题.
这导致我在安装和重新安装lxml,熊猫,html5lib,html,然后从我的机器和Spyder删除所有Python的兔子洞,然后重新安装所有的东西,但仍然有同样的错误"lxml找不到.“
于是,我在命令行、lxml和大熊猫上做了“pip list”,我安装的所有东西都在那里。
我找到了一些代码来查找所有安装在Spyder上的包/库,使用以下代码: import pkg_resources
dists = [str(d).replace(" ","==") for d in pkg_resources.working_set]
for i in dists:
print(i)
我得到了:
runfile('C:/Users/Preston_Jarvis/untitled0.py', wdir='C:/Users/Preston_Jarvis')
zipp==3.4.1
yapf==0.31.0
wheel==0.36.2
webencodings==0.5.1
wcwidth==0.2.5
And so on...
熊猫在那里,但是lxml或者html5lib或者hmtl。
是什么导致了这一切?
谢谢
发布于 2021-09-25 12:41:41
你是怎么安装Spyder的?您是使用安装程序还是用pip/conda安装它?你在哪里安装你的软件包-什么环境?
使用pip (例如lxml)安装包的环境似乎与Spyder运行的环境不同。请参阅https://docs.spyder-ide.org/current/faq.html#using-existing-environment
请注意,为了使Spyder与其他环境一起工作,您需要在此环境中安装spyder-核(例如,pip install spyder-kernels
)。
https://stackoverflow.com/questions/69320452
复制