Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import spacy fails in pydroid3 due to ujson strreverse error #2955

Closed
InputMoe opened this issue Nov 21, 2018 · 4 comments
Closed

Import spacy fails in pydroid3 due to ujson strreverse error #2955

InputMoe opened this issue Nov 21, 2018 · 4 comments
Labels
install Installation issues third-party Third-party packages and services

Comments

@InputMoe
Copy link

How to reproduce the behaviour

After successful installation:

python -m spacy download en

or

import spacy

Do not work and produce the following error message:

Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), main.dict)
File "", line 1, in
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/spacy/init.py", line 10, in
from .cli.info import info as cli_info
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/spacy/cli/init.py", line 1, in
from .download import download
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/spacy/cli/download.py", line 11, in
from .link import link
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/spacy/cli/link.py", line 8, in
from ..compat import symlink_to, path2str
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/spacy/compat.py", line 5, in
import ujson
ImportError: dlopen failed: cannot locate symbol "strreverse" referenced by "/data/data/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/ujson.cpython-36m.so"...

Your Environment

  • Operating System: executed on Android 8 in the app Pydroid 3
  • Python Version Used: 3.6.2
  • spaCy Version Used: 2.0.16
  • Environment Information:
@ines ines added install Installation issues third-party Third-party packages and services labels Nov 24, 2018
@honnibal
Copy link
Member

honnibal commented Nov 26, 2018

This is unfortunate, but I'm not sure we'll be able to resolve this. So is that a system library that the platform is missing, or...?

Here's a suggestion for how you might be able to work around this. You could package a Python library called ujson that simply consists of a __init__.py that simply does from json import *. You'd then have to make sure this dummy ujson package has a version number within the range that spaCy expects. If you install this package before installing spaCy, pip should see that the ujson dependency is satisfied by your package, and won't install the real ujson from PyPi.

@ines
Copy link
Member

ines commented Nov 26, 2018

One thing to note: I'm not 100% sure but it's possible that spaCy uses ujson-specific method arguments that the regular json module doesn't have. So if you see weird errors about unknown arguments, you might have to mock those (e.g. by making your fake ujson module expose a method that catches those arguments but does nothing). But fingers crossed everything works and you won't have to 🤞

@InputMoe
Copy link
Author

Thx for your answers. I tried the following:

I replaced:
import ujson

in every file by:

try: import ujson except ImportError: import simplejson as ujson

and amended the requirements.txt with simplejson.

It worked for me and I could use it on android.

I didnt test it on other plattforms. But if no specific ujson methods are used, it should work fine on all other platforms.

@ines ines closed this as completed Nov 26, 2018
@lock
Copy link

lock bot commented Dec 26, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
install Installation issues third-party Third-party packages and services
Projects
None yet
Development

No branches or pull requests

3 participants