我有个问题。
我正在尝试在Linux机器上安装spacy,但是此命令给我很多错误:

pip3 install spacy


这是我尝试安装时得到的输出:

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


这是它给出的所有错误的相关输出。
我不知道该怎么办,但是我需要它与之合作!
我正在使用Raspbian buster lite在Raspberry Pi 3上运行。

更新
现在,在下载源代码并将您的代码粘贴到setup.py中,然后使用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


有什么建议么?

最佳答案

因为您要在Rasp上编译spacy。但是GCC在ARM平台上不支持这些标志。


  gcc:注意:有效参数为: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本机
      gcc:错误:缺少“ -march =”的参数
      gcc:错误:无法识别的命令行选项“ -mavx2”
      gcc:错误:无法识别的命令行选项“ -mfma”
      gcc:错误:无法识别的命令行选项“ -mfpmath = sse”


因此,为了使其在您的平台上运行,建议您使用--disable-sse2选项运行configure。这意味着您可以下载spacy源代码,然后自己修改或配置其Makefile。然后尝试python setup.py install

您可能需要了解此setup.pyMakefile

要更改setup.py以适合您的平台,可以修改some code,例如:

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

关于python - 无法安装spacy,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57507915/

10-12 21:09