-
说明
尝试翻译Cython Documentation以助学习。
水平有限,乐迎指正;文档首页:《Cython官方文档中文翻译》
-
安装Cython
许多系统的
Python
发行版,比如Anaconda
[Anaconda],Enthought Canopy
[Canopy],Sage
[Sage],内置捆绑Cython
,因此无需额外安装。当然,如果你的Python发行版种绑定的Cython版本太久,可以通过下述指令进行更新。除非特别说明,本教程中的所有内容适于Cython 0.11.2及之后版本。不想大部分
Python
软件,Cython
需要C编译器。依据所用系统不同,获取C编译器
的方式也有所不同:-
Linux
GUN C Compiler(GCC)
一般是自带的,也很容易通过包管理系统获取。例如,在Ubuntu
或Debian
:sudo apt-get install build-essential
-
Mac OS 可以通过安装
Apple
的XCode
来检索gcc
,至于XCode
,可以通过Mac OS X
的安装光盘或此网址获取。 -
Windows 常用开源软件
MinGW
(gcc
的Windows
版本)。手动设置MinGW
的说明参见附录。虽然Enthought Canopy and Python(x,y)
有捆绑MinGW
,附录种的配置环节仍然是有必要看一下的。另一个方案是使用Microsoft Visual C
,必须与编译已安装Python
的版本一致。(不太理解,原文是One must then use the same version which the installed Python was compiled with.)
最简单的
Cython
安装方式是采用pip
:pip install Cython
https://cython.org/可下载最新的
Cython发行版本
,解压后,进入文件夹,然后运行:python setup.py install
对于一次性构建(
builds
),例如CI/testing
,在PyPI
上任意轮包都未覆盖的平台上,安装未编译(慢)的Cython
版本要比全代码构建
(full source build
)快得多:pip install Cython --install-option-"--no-cython-compile"
-
-
相关软件
[Anaconda] https://docs.anaconda.com/anaconda/
[Canopy] https://www.enthought.com/product/canopy/
[Sage] Stein et al., Sage Mathematics Software, https://www.sagemath.org/
Cython官方文档中文翻译:安装Cython
最新推荐文章于 2024-04-15 16:41:54 发布