我目前正在开发一个项目,需要在AWS窗口实例上上传并运行django项目。我已经测试了这个项目,并且在我的台式机和笔记本电脑上运行良好,没有任何问题。但是,当我上传到 AWS 时,我无法安装该项目所需的 TTS 库。首先,我使用Python 3.11.9,然后我降级到3.10.8,因为我听说它更稳定。我还安装了带有 Windows 11 SDK 的 C++ v14。安装Spacy时出现错误。我尝试单独安装 Spacy,它工作正常,但在构建 Wheel 时出现错误。我的猜测是 SDK 版本安装不正确或者实例类型不够强大(我目前使用的是 t3-large)。有谁遇到过这个问题请帮忙。预先感谢。
Using cached spacy-3.0.6.tar.gz (7.1 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [164 lines of output]
Error compiling Cython file:
------------------------------------------------------------
...
int length
cdef class Vocab:
cdef Pool mem
cpdef readonly StringStore strings
^
------------------------------------------------------------
spacy\vocab.pxd:28:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Error compiling Cython file:
------------------------------------------------------------
...
cdef class Vocab:
cdef Pool mem
cpdef readonly StringStore strings
cpdef public Morphology morphology
^
------------------------------------------------------------
spacy\vocab.pxd:29:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Error compiling Cython file:
------------------------------------------------------------
...
cdef class Vocab:
cdef Pool mem
cpdef readonly StringStore strings
cpdef public Morphology morphology
cpdef public object vectors
^
------------------------------------------------------------
spacy\vocab.pxd:30:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Error compiling Cython file:
------------------------------------------------------------
...
cdef class Vocab:
cdef Pool mem
cpdef readonly StringStore strings
cpdef public Morphology morphology
cpdef public object vectors
cpdef public object _lookups
^
------------------------------------------------------------
spacy\vocab.pxd:31:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Error compiling Cython file:
------------------------------------------------------------
...
cdef Pool mem
cpdef readonly StringStore strings
cpdef public Morphology morphology
cpdef public object vectors
cpdef public object _lookups
cpdef public object writing_system
^
------------------------------------------------------------
spacy\vocab.pxd:32:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Error compiling Cython file:
------------------------------------------------------------
...
cpdef readonly StringStore strings
cpdef public Morphology morphology
cpdef public object vectors
cpdef public object _lookups
cpdef public object writing_system
cpdef public object get_noun_chunks
^
------------------------------------------------------------
spacy\vocab.pxd:33:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Error compiling Cython file:
------------------------------------------------------------
...
cdef float prior_prob
cdef class KnowledgeBase:
cdef Pool mem
cpdef readonly Vocab vocab
^
------------------------------------------------------------
spacy\kb.pxd:31:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Copied C:\Users\Administrator\AppData\Local\Temp\2\pip-install-kxff7n82\spacy_67c11f539ddc49f59b8b663ae8274dab\setup.cfg -> C:\Users\Administrator\AppData\Local\Temp\2\pip-install-kxff7n82\spacy_67c11f539ddc49f59b8b663ae8274dab\spacy\tests\package
Copied C:\Users\Administrator\AppData\Local\Temp\2\pip-install-kxff7n82\spacy_67c11f539ddc49f59b8b663ae8274dab\pyproject.toml -> C:\Users\Administrator\AppData\Local\Temp\2\pip-install-kxff7n82\spacy_67c11f539ddc49f59b8b663ae8274dab\spacy\tests\package
Cythonizing sources
Compiling spacy/training/example.pyx because it changed.
Compiling spacy/parts_of_speech.pyx because it changed.
Compiling spacy/strings.pyx because it changed.
Compiling spacy/lexeme.pyx because it changed.
Compiling spacy/vocab.pyx because it changed.
Compiling spacy/attrs.pyx because it changed.
Compiling spacy/kb.pyx because it changed.
Compiling spacy/ml/parser_model.pyx because it changed.
Compiling spacy/morphology.pyx because it changed.
Compiling spacy/pipeline/dep_parser.pyx because it changed.
Compiling spacy/pipeline/morphologizer.pyx because it changed.
Compiling spacy/pipeline/multitask.pyx because it changed.
Compiling spacy/pipeline/ner.pyx because it changed.
Compiling spacy/pipeline/pipe.pyx because it changed.
Compiling spacy/pipeline/trainable_pipe.pyx because it changed.
Compiling spacy/pipeline/sentencizer.pyx because it changed.
Compiling spacy/pipeline/senter.pyx because it changed.
Compiling spacy/pipeline/tagger.pyx because it changed.
Compiling spacy/pipeline/transition_parser.pyx because it changed.
Compiling spacy/pipeline/_parser_internals/arc_eager.pyx because it changed.
Compiling spacy/pipeline/_parser_internals/ner.pyx because it changed.
Compiling spacy/pipeline/_parser_internals/nonproj.pyx because it changed.
Compiling spacy/pipeline/_parser_internals/_state.pyx because it changed.
Compiling spacy/pipeline/_parser_internals/stateclass.pyx because it changed.
Compiling spacy/pipeline/_parser_internals/transition_system.pyx because it changed.
Compiling spacy/pipeline/_parser_internals/_beam_utils.pyx because it changed.
Compiling spacy/tokenizer.pyx because it changed.
Compiling spacy/training/align.pyx because it changed.
Compiling spacy/training/gold_io.pyx because it changed.
Compiling spacy/tokens/doc.pyx because it changed.
Compiling spacy/tokens/span.pyx because it changed.
Compiling spacy/tokens/token.pyx because it changed.
Compiling spacy/tokens/span_group.pyx because it changed.
Compiling spacy/tokens/graph.pyx because it changed.
Compiling spacy/tokens/morphanalysis.pyx because it changed.
Compiling spacy/tokens/_retokenize.pyx because it changed.
Compiling spacy/matcher/matcher.pyx because it changed.
Compiling spacy/matcher/phrasematcher.pyx because it changed.
Compiling spacy/matcher/dependencymatcher.pyx because it changed.
Compiling spacy/symbols.pyx because it changed.
Compiling spacy/vectors.pyx because it changed.
[ 1/41] Cythonizing spacy/attrs.pyx
[ 2/41] Cythonizing spacy/kb.pyx
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-qx2w3xqu\overlay\Lib\site-packages\setuptools\build_meta.py", line 333, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-qx2w3xqu\overlay\Lib\site-packages\setuptools\build_meta.py", line 303, in _get_build_requires
self.run_setup()
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-qx2w3xqu\overlay\Lib\site-packages\setuptools\build_meta.py", line 319, in run_setup
exec(code, locals())
File "<string>", line 224, in <module>
File "<string>", line 211, in setup_package
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-qx2w3xqu\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
cythonize_one(*args)
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-qx2w3xqu\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: spacy/kb.pyx
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
您可以在这里找到解决方案:https://github.com/explosion/spaCy/discussions/12941
简而言之,你需要使用以前版本的 cython:
pip install Cython==0.29.36
pip install spacy==3.0.6 --no-build-isolation