问题描述
我的 CentOS 已经安装了如下图所示的 Cython,但是我在编译一个 cython 项目时仍然收到以下错误,在 Ubuntu 或 MacOS 上没有这个问题:
sudo python setup.py build_ext --inplace
Cythonizing sources
Processing token.pyx
Traceback (most recent call last):
File "<string>",line 1,in <module>
File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py",line 840,in setuptools_main
return main(command_line = 1)
File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py",line 858,in main
result = compile(sources,options)
File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py",line 780,in compile
return compile_multiple(source,line 750,in compile_multiple
context = options.create_context()
File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py",line 597,in create_context
self.cplus,self.language_level,options=self)
File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py",line 80,in __init__
from . import Builtin,CythonScope
File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/CythonScope.py",line 5,in <module>
from .UtilityCode import CythonUtilityCode
File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/UtilityCode.py",line 3,in <module>
from .TreeFragment import parse_from_strings,StringParseContext
File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/TreeFragment.py",line 17,in <module>
from .Visitor import VisitorTransform
File "Cython/Compiler/Visitor.py",line 12,in init Cython.Compiler.Visitor
File "/usr/local/lib/python3.7/inspect.py",line 40,in <module>
import linecache
File "/usr/local/lib/python3.7/linecache.py",line 11,in <module>
import tokenize
File "/usr/local/lib/python3.7/tokenize.py",line 35,in <module>
from token import *
File "stringsource",line 105,in init spacy.tokens.token
AttributeError: type object 'spacy.tokens.token.array' has no attribute '__reduce_cython__'
Traceback (most recent call last):
File "/data0/congmin/wb-nlp-tool/spaCy-weibo/bin/cythonize.py",line 60,in process_pyx
["cython"] + flags + ["-o",tofile,fromfile],env=os.environ
File "/usr/local/lib/python3.7/subprocess.py",line 323,in call
with Popen(*popenargs,**kwargs) as p:
File "/usr/local/lib/python3.7/subprocess.py",line 775,in __init__
restore_signals,start_new_session)
File "/usr/local/lib/python3.7/subprocess.py",line 1522,in _execute_child
raise child_exception_type(errno_num,err_msg,err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'cython': 'cython'
During handling of the above exception,another exception occurred:
Traceback (most recent call last):
File "/data0/congmin/wb-nlp-tool/spaCy-weibo/bin/cythonize.py",line 169,in <module>
run(args.root)
File "/data0/congmin/wb-nlp-tool/spaCy-weibo/bin/cythonize.py",line 158,in run
process(base,filename,db)
File "/data0/congmin/wb-nlp-tool/spaCy-weibo/bin/cythonize.py",line 124,in process
preserve_cwd(base,process_pyx,root + ".pyx",root + ".cpp")
File "/data0/congmin/wb-nlp-tool/spaCy-weibo/bin/cythonize.py",line 87,in preserve_cwd
func(*args)
File "/data0/congmin/wb-nlp-tool/spaCy-weibo/bin/cythonize.py",line 78,in process_pyx
raise Exception("Cython Failed")
Exception: Cython Failed
Traceback (most recent call last):
File "setup.py",line 200,in <module>
setup_package()
File "setup.py",line 188,in setup_package
generate_cython(root,"spacy")
File "setup.py",line 115,in generate_cython
raise RuntimeError("Running cythonize Failed")
RuntimeError: Running cythonize Failed
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)