Python – Unable to import name ‘etree’

Unable to import name ‘etree’… here is a solution to the problem.

Unable to import name ‘etree’

An

error occurred while trying to run sample .py from the serpscrap package.

I use iPhoneX in Pythonista.

Any help would be appreciated.

This is backtracking

Traceback (most recent call last):
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/testing/serpscrapetest.py", line 3, in <module>
    import serpscrap
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/site-packages-3/serpscrap/__init__.py", line 5, in < module>
    from serpscrap.serpscrap import SerpScrap
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/site-packages-3/serpscrap/serpscrap.py", line 11, in < module>
    from scrapcore.core import Core
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/site-packages-3/scrapcore/core.py", line 8, in <module >
    from scrapcore.cachemanager import CacheManager
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/site-packages-3/scrapcore/cachemanager.py", line 11, in <module>
    from scrapcore.parsing import Parsing
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/site-packages-3/scrapcore/parsing.py", line 6, in < module>
    from scrapcore.parser.google_parser import GoogleParser
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/site-packages-3/scrapcore/parser/google_parser.py", line 7, in <module>
    from scrapcore.parser.parser import Parser
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/site-packages-3/scrapcore/parser/parser.py", line 7, in <module>
    import lxml.html
  File "/private/var/mobile/Containers/Shared/AppGroup/C27C5B11-1804-47B9-AF18-7287A8337C55/Pythonista3/Documents/site-packages-3/lxml/html/__init__.py", line 54, in < module>
    from .. import etree
ImportError: cannot import name 'etree'

Solution

SerpScrap does not currently run on iOS because of lxml dependencies.
I will update the documentation to clarify this.

But maybe you can look at https://github.com/pybee/Python-Apple-support .
I’m not familiar with iOS, maybe someone can check if this helps with this. Otherwise, feel free to ask questions on the Serpscrap GitHub page.

Related Problems and Solutions