-1

I have a problem. I am trying to install spacy on my linux machine, but it gives me lots of errors with this command:

pip3 install spacy

This is the output I get when I try to install it:

Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-srt_eep7 --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools wheel>0.32.0,<0.33.0 Cython cymem>=2.0.2,<2.1.0 preshed>=2.0.1,<2.1.0 murmurhash>=0.28.0,<1.1.0 thinc>=7.0.8,<7.1.0" failed with error code 1 in None

This is relevant output of all the errors that it gives. I have no idea what to do, but I need it to work with!?
I am running on a Raspberry Pi 3 with Raspbian buster lite.

UPDATE Now I get this message after downloading the source code and pasting your code in the setup.py and then running it with python /spacy/setup.py:

Cythonizing sources
Processing kb.pyx
Traceback (most recent call last):
  File "/root/.env/bin/cython", line 10, in <module>
    sys.exit(setuptools_main())
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 840, in setuptools_main
    return main(command_line = 1)
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 858, in main
    result = compile(sources, options)
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 780, in compile
    return compile_multiple(source, options)
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 750, in compile_multiple
    context = options.create_context()
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 597, in create_context
    self.cplus, self.language_level, options=self)
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 80, in __init__
    from . import Builtin, CythonScope
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/CythonScope.py", line 5, in <module>
    from .UtilityCode import CythonUtilityCode
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/UtilityCode.py", line 3, in <module>
    from .TreeFragment import parse_from_strings, StringParseContext
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/TreeFragment.py", line 17, in <module>
    from .Visitor import VisitorTransform
  File "Cython/Compiler/Visitor.py", line 17, in init Cython.Compiler.Visitor
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/ExprNodes.py", line 4724, in <module>
    class SliceIndexNode(ExprNode):
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/ExprNodes.py", line 4922, in SliceIndexNode
    "SliceObject", "ObjectHandling.c", context={'access': 'Get'})
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Code.py", line 404, in load
    return cls(**kwargs)
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Code.py", line 648, in __init__
    proto = sub_tempita(proto, context, file, name)
  File "/root/.env/lib/python3.4/site-packages/Cython/Compiler/Code.py", line 640, in sub_tempita
    from ..Tempita import sub
  File "/root/.env/lib/python3.4/site-packages/Cython/Tempita/__init__.py", line 4, in <module>
    from ._tempita import *
ImportError: /root/.env/lib/python3.4/site-packages/Cython/Tempita/_tempita.cpython-34m.so: undefined symbol: PyFPE_jbuf
Traceback (most recent call last):
  File "/root/spaCy/bin/cythonize.py", line 169, in <module>
    run(args.root)
  File "/root/spaCy/bin/cythonize.py", line 158, in run
    process(base, filename, db)
  File "/root/spaCy/bin/cythonize.py", line 124, in process
    preserve_cwd(base, process_pyx, root + ".pyx", root + ".cpp")
  File "/root/spaCy/bin/cythonize.py", line 87, in preserve_cwd
    func(*args)
  File "/root/spaCy/bin/cythonize.py", line 63, in process_pyx
    raise Exception("Cython failed")
Exception: Cython failed
Traceback (most recent call last):
  File "setup.py", line 278, in <module>
    setup_package()
  File "setup.py", line 211, in setup_package
    generate_cython(root, "spacy")
  File "setup.py", line 134, in generate_cython
    raise RuntimeError("Running cythonize failed")
RuntimeError: Running cythonize failed

Any suggestions?

A. Vreeswijk
  • 822
  • 1
  • 19
  • 57
  • try `sudo apt-get install gcc python-dev` before run `pip`. – Frank AK Aug 15 '19 at 10:12
  • Are you sure, please post the latest information here – Frank AK Aug 15 '19 at 10:21
  • I will copy/paste the output what I get now! – A. Vreeswijk Aug 15 '19 at 10:21
  • Its updated with the last response – A. Vreeswijk Aug 15 '19 at 10:22
  • 1
    There are prebuilt wheels of `spacy` for Raspbian, but not for all Python versions; which one do you use? You might try running `pip3 install spacy --only-binary=spacy`, if you use Python 3.6 or older, the command should install just fine. – hoefling Aug 15 '19 at 20:52
  • hi @hoefling after running your command: ```Could not find a version that satisfies the requirement spacy (from versions: ) No matching distribution found for spacy``` – Franva Jan 27 '20 at 09:06
  • hi @A.Vreeswijk have you made it? – Franva Jan 27 '20 at 09:26
  • @Franva "no matching distributions" means there are no prebuilt wheels for your Python/ABI combination. Run `python -c "from pip._internal.pep425tags import get_supported; print(get_supported()[0])"`, what do you get? – hoefling Jan 27 '20 at 10:44
  • hi @hoefling ```('cp37', 'cp37m', 'linux_armv7l')``` thanks for your reply. I have been stuck here for the entire day, tried at least 10 approaches to make it work, but still no luck... – Franva Jan 27 '20 at 10:55
  • @Franva unfortunately, there are no prebuilt wheels for Python 3.7 on RPi (the platform is ok though). Either switch to Python 3.6 or [install from source](https://spacy.io/usage#source), refer also to the given answer for ARM-specific tweaks. – hoefling Jan 27 '20 at 11:13
  • hi @hoefling thanks for your tips. I actually have tried to install from source. It throws out the same error. – Franva Jan 27 '20 at 11:36
  • hi @hoefling here is the detailed error: https://stackoverflow.com/questions/59927844/is-it-possible-to-install-spacy-to-raspberry-pi-4-raspbian-buster – Franva Jan 27 '20 at 11:53

1 Answers1

2

Since you want to compile spacy on Rasp. but GCC doesn't support those flags on the ARM platform.

gcc: note: valid arguments are: armv2 armv2a armv3 armv3m armv4 armv4t armv5 armv5t armv5e armv5te armv5tej armv6 armv6j armv6k armv6z armv6kz armv6zk armv6t2 armv6-m armv6s-m armv7 armv7-a armv7ve armv7-r armv7-m armv7e-m armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8-m.base armv8-m.main armv8-r iwmmxt iwmmxt2 native gcc: error: missing argument to ‘-march=’ gcc: error: unrecognized command line option ‘-mavx2’ gcc: error: unrecognized command line option ‘-mfma’ gcc: error: unrecognized command line option ‘-mfpmath=sse’

So, to make it work on your platform, I suggest you run configure with the option --disable-sse2. it means you can download the spacy source code and then modify or configure its Makefile by yourself. and then try python setup.py install.

You may need to know about this setup.py and Makefile

To change setup.py to suit your platform, you can modify some code, for example:

if is_new_osx():
    # On Mac, use libc++ because Apple deprecated use of
    # libstdc
    COMPILE_OPTIONS["other"].append("-stdlib=libc++")
    LINK_OPTIONS["other"].append("-lc++")
    # g++ (used by unix compiler on mac) links to libstdc++ as a default lib.
    # See: https://stackoverflow.com/questions/1653047/avoid-linking-to-libstdc
    LINK_OPTIONS["other"].append("-nodefaultlibs")
    # Because I am running it on my Rasp Pi
    # I want to remove some options from LINK_OPTIONS or Add some into it
Frank AK
  • 1,705
  • 15
  • 28
  • What do I need to configure in the Makefile? – A. Vreeswijk Aug 15 '19 at 10:35
  • I have added an Update to my question with the next error :( – A. Vreeswijk Aug 15 '19 at 11:17
  • And you said: "To change setup.py to suit your platform, you can modify some code", but how can I know if it suits my platform? – A. Vreeswijk Aug 15 '19 at 13:35
  • hi @FrankAK could you please help? I'm on Raspbian Buster. Is it possible to do the similar trick here? I've had a look and cannot find anything to change. please help, thanks – Franva Jan 27 '20 at 09:50
  • @Franva Well, it depends, could you post your question on SO? – Frank AK Feb 14 '20 at 04:39
  • thanks @FrankAK I have got my answer from there: https://stackoverflow.com/questions/59927844/is-it-possible-to-install-spacy-to-raspberry-pi-4-raspbian-buster/59957172?noredirect=1#comment106081791_59957172 – Franva Feb 17 '20 at 05:11