Investpy 安装有什么问题?

What's wrong with the Investpy installation?

我的一个脚本正在导入 Investpy 库,当我检查 Investpy 就位的站点包时,我遇到了以下错误消息。

Traceback (most recent call last):
  File "/Users/LSH/WSFG_DEV/workspace/telegram_bot/roe_eps_check.py", line 9, in <module>
    import investpy
  File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/investpy/__init__.py", line 7, in <module>
    from .stocks import get_stocks, get_stocks_list, get_stocks_dict, get_stock_countries, get_stock_recent_data, \
  File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/investpy/stocks.py", line 16, in <module>
    from lxml.html import fromstring
  File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/lxml/html/__init__.py", line 53, in <module>
    from .. import etree
ImportError: cannot import name 'etree' from 'lxml' (/Users/LSH/Library/Python/3.8/lib/python/site-packages/lxml/__init__.py)
LSH@LSHs-Air workspace % 

有谁知道哪里出了问题?我已经删除并重新安装了 Investpy,但没有成功。

谢谢大家!! :)

您可以尝试这样做:

pip install lxml-4.6.3-cp38-cp38-win_amd64

python -m pip install lxml==3.6.0

如果这不能解决问题,请卸载 lxml 并使用 pip

重新安装它

来源:

ImportError: cannot import name 'etree' on Python 3.6