-1

One of my script is importing Investpy library and I encoutered the following error message when I have checked the site-package the Investpy is in place.

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 % 

Does anyone know what is wrong? I have already remove and re-install Investpy but no luck.

Thank you everyone!! :)

Woody
  • 125
  • 1
  • 11
  • 1
    Does this answer your question? [ImportError: cannot import name 'etree' on Python 3.6](https://stackoverflow.com/questions/53406638/importerror-cannot-import-name-etree-on-python-3-6) – Random Davis Jul 21 '21 at 15:12

1 Answers1

1

You could try and do:

pip install lxml-4.6.3-cp38-cp38-win_amd64

OR

python -m pip install lxml==3.6.0

If this doesn't fix the issue, uninstall lxml and reinstall it using pip

Source:

ImportError: cannot import name 'etree' on Python 3.6

  • I am using MacOS, so the 1st command should not be used. the 2nd command has been tried, as I only got pip3 , pip will not work – Woody Jul 21 '21 at 15:46