Python Cython AttributeError:“module”对象没有属性“declare”
编译.pyx文件工作正常,但当我键入以下内容时,突然出现了错误:Python Cython AttributeError:“module”对象没有属性“declare”,python,cython,attributeerror,Python,Cython,Attributeerror,编译.pyx文件工作正常,但当我键入以下内容时,突然出现了错误: python setup.py build_ext --inplace 我得到一个错误: c:\Python27\cython\helloworld>python setup.py build_ext --inplace running build_ext cythoning hello.pyx to hello.c Traceback (most recent call last): File "setup.py",
python setup.py build_ext --inplace
我得到一个错误:
c:\Python27\cython\helloworld>python setup.py build_ext --inplace
running build_ext
cythoning hello.pyx to hello.c
Traceback (most recent call last):
File "setup.py", line 8, in <module>
ext_modules = [Extension("hello", ["hello.pyx"])]
File "C:\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\Cython\Distutils\build_ext.py", line 163,
in run
_build_ext.build_ext.run(self)
File "C:\Python27\lib\distutils\command\build_ext.py", line 340, in run
self.build_extensions()
File "C:\Python27\lib\site-packages\Cython\Distutils\build_ext.py", line 170,
in build_extensions
ext.sources = self.cython_sources(ext.sources, ext)
File "C:\Python27\lib\site-packages\Cython\Distutils\build_ext.py", line 317,
in cython_sources
full_module_name=module_name)
File "C:\Python27\lib\site-packages\Cython\Compiler\Main.py", line 605, in com
pile
return compile_single(source, options, full_module_name)
File "C:\Python27\lib\site-packages\Cython\Compiler\Main.py", line 546, in com
pile_single
return run_pipeline(source, options, full_module_name)
File "C:\Python27\lib\site-packages\Cython\Compiler\Main.py", line 386, in run
_pipeline
import Pipeline
File "C:\Python27\lib\site-packages\Cython\Compiler\Pipeline.py", line 7, in <
module>
from Visitor import CythonTransform
File "Visitor.py", line 9, in init Cython.Compiler.Visitor (Cython\Compiler\Vi
sitor.c:12838)
File "C:\Python27\lib\site-packages\Cython\Compiler\Nodes.py", line 6, in <mod
ule>
cython.declare(sys=object, os=object, copy=object,
AttributeError: 'module' object has no attribute 'declare'
使用setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("hello", ["hello.pyx"])]
)
它已经运行了好几次,有些东西已经改变了,但当我在谷歌上搜索这个问题时,我找不到任何信息。我正在使用Python 2.7 64位,Cython的最新版本,为了编译该文件,我使用Windows SDK C/C++编译器,并通过运行以下命令准备环境:
C:\Program Files\Microsoft SDKs\Windows\v7.0>set DISTUTILS_USE_SDK=1
C:\Program Files\Microsoft SDKs\Windows\v7.0>setenv /x64 /release
你知道会发生什么吗?提前通知Tnx 我不确定这是否有帮助,但当我遇到此错误时,我删除了所有.pyc文件,并通过IDLE再次运行脚本,在IDLE中打开并单击F5,然后它工作正常。我不确定这是否有帮助,但是当我遇到这个错误时,我删除了所有的.pyc文件,并通过IDLE再次运行脚本,在IDLE中打开并单击F5,然后它工作正常。我也遇到了同样的错误。 我花了整整一天的时间研究它,直到我意识到我在我的目录中创建了一个cython.py文件,其中包含了一些如何编译的信息。
我不记得是在哪里找到的,但通过删除此文件,一切正常我遇到了相同的错误。 我花了整整一天的时间研究它,直到我意识到我在我的目录中创建了一个cython.py文件,其中包含了一些如何编译的信息。
我不记得是在哪里找到的,但通过删除此文件,一切正常从python脚本运行时,我遇到了相同的错误:
os.system("python setup.py build_ext --inplace")
当
python setup.py build_ext --inplace
在指挥部工作
原因是我的测试包名是cython。。。愚蠢的我从python脚本运行时,我遇到了相同的错误:
os.system("python setup.py build_ext --inplace")
当
python setup.py build_ext --inplace
在指挥部工作
原因是我的测试包名是cython。。。愚蠢的我可能有助于理解导入的作用:Tnx为此,我将进行研究,看看是否能找到什么!可能有助于理解导入的作用:Tnx为此,我将进行研究,看看是否能找到一些东西!