相关疑难解决方法(0)

如何在Cython的setup.py中指定Python 3源?

我正在尝试根据本教程http://docs.cython.org/src/tutorial/cython_tutorial.html#cython-hello-world在Cython中创建“ Hello World”程序

我创建了helloworld.pyx

print("Hello World")
Run Code Online (Sandbox Code Playgroud)

和setup.py:

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloworld.pyx")
)
Run Code Online (Sandbox Code Playgroud)

如何更改setup.py以指定源是Python 3,而不是本教程中的Python 2?如果我从命令行调用“ cython”命令,它将接受-3选项。但是,如果我python setup.py build_ext --inplace按照本教程中所示进行编译,该如何指定Python 3源?对于Hello World程序来说,它可能无关紧要,但是随着我开始在实际项目中使用Cython时,它会变得很重要。

非常感谢!

python cython python-3.x

15
推荐指数
3
解决办法
1万
查看次数

cython的setup.py中的language_level有什么作用?

如果设置language_level=2ext_modules = cythonize(extensions, language_level=2),那会发生什么变化?只是我编写的代码应该解释为Python2吗?

最终结果完全一样吗?

cython

3
推荐指数
1
解决办法
1071
查看次数

Cython 在 Windows 中使用 mingw64 编译错误“无法将类型 'double' 分配给 'int'”,但在 linux 中正常

我在安装traj-dist 使用Cython. 在Linux下使用gcc编译后可以安装,但在winodws下使用mingw64 gcc编译后无法安装。

我使用Python 3.8,Cython 0.29.21。

python setup.py build_ext --inplace --force

完整的输出错误消息在这里

Error compiling Cython file:
------------------------------------------------------------
...
    q=len(Q)

    cc=_compute_critical_values(P,Q,p,q)
    eps=cc[0]
    while(len(cc)!=1):
        m_i=len(cc)/2-1
                    ^
------------------------------------------------------------

traj_dist\cydist\frechet.pyx:535:21: Cannot assign type 'double' to 'int'
Run Code Online (Sandbox Code Playgroud)

有编译错误的文件是https://github.com/bguillouet/traj-dist/blob/master/traj_dist/cydist/frechet.pyx

我怎样才能在windows下编译它?

python cython

1
推荐指数
1
解决办法
4539
查看次数

标签 统计

cython ×3

python ×2

python-3.x ×1