3

I am getting an error when trying to run a example .py from the serpscrap package.

I am on an iPhoneX in Pythonista.

Any help would be greatly appreciated.

Here is the traceback

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' 

2 Answers 2

2

SerpScrap doesn't work on iOS at the moment, because of the lxml dependency. I will update the docs to clearify this point.

But maybe you take a look on https://github.com/pybee/Python-Apple-support . I'm not familiar with iOS, maybe someone can check if this can help to solve this issue. Otherwise feel free to open an issue on the serpscrap github page.

Sign up to request clarification or add additional context in comments.

Comments

1

serpscrap evidently requires lxml, even though for some reason it only documents that requirement for Windows, rather than for all platforms.

You can't install packages that need C extension modules, like lxml, in Pythonista. You seem to have somehow gotten the pure-Python part of lxml installed,1 but that won't do any good without the C extension modules.

There's an open issue, #245, to add lxml as a pre-installed package with Pythonista, which would probably fix your problem.

So, your options are:

  • Help Pythonista get lxml building so they can close that bug and add lxml to the next version.
  • Modify serpscrap to work without lxml (if it's just using lxml.etree, it's possible that it would work with the stdlib ETree implementation).
  • File a feature request with serpscrap and hope someone else does it.
  • Switch to a different scraper that doesn't require lxml.

1. I'm not sure how that could happen; the install should just fail. But maybe serpscrap does some weird thing that happens to work on Linux and macOS but not iOS, and that's why they only list lxml as a dependency on Windows in the first place?

13 Comments

@JakeWalter No, I don't.
I installed lxml with pip
Pythonista comes with examples using c so I don’t understand why you are saying that it can’t use c ?
@JakeWalter Which examples? The docs say C extensions don’t work. There are open issues asking for specific modules to be added because C extensions don’t work. I’m not making this up to make your life harder, and arguing with me isn’t going to make your code start working.
c extensions wont work in pythonista. pythonista has a bridge to the ios Objective C runtime, but that is not fresh compiled c code -- the runtime is written in c, but operates based on messages, which we can send, and bridge functions back to python code.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.