- Cython 0.29.36
- Навигация
- Ссылки проекта
- Статистика
- Метаданные
- Сопровождающие
- Классификаторы
- Описание проекта
- Installing Cython¶
- How To Install cython on Ubuntu 20.04
- What is cython
- Install cython Using apt-get
- Install cython Using apt
- Install cython Using aptitude
- How To Uninstall cython on Ubuntu 20.04
- Uninstall cython And Its Dependencies
- Remove cython Configurations and Data
- Remove cython configuration, data, and all of its dependencies
- References
- Summary
- Installing Cython¶
Cython 0.29.36
The Cython compiler for writing C extensions for the Python language.
Навигация
Ссылки проекта
Статистика
Метаданные
Лицензия: Apache Software License (Apache)
Требует: Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*
Сопровождающие
Классификаторы
- Development Status
- 5 — Production/Stable
- Developers
- OSI Approved :: Apache Software License
- OS Independent
- C
- Cython
- Python
- Python :: 2
- Python :: 2.6
- Python :: 2.7
- Python :: 3
- Python :: 3.4
- Python :: 3.5
- Python :: 3.6
- Python :: 3.7
- Python :: 3.8
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: Implementation :: CPython
- Python :: Implementation :: PyPy
- Software Development :: Code Generators
- Software Development :: Compilers
- Software Development :: Libraries :: Python Modules
Описание проекта
The Cython language makes writing C extensions for the Python language as easy as Python itself. Cython is a source code translator based on Pyrex, but supports more cutting edge functionality and optimizations.
The Cython language is a superset of the Python language (almost all Python code is also valid Cython code), but Cython additionally supports optional static typing to natively call C functions, operate with C++ classes and declare fast C types on variables and class attributes. This allows the compiler to generate very efficient C code from Cython code.
This makes Cython the ideal language for writing glue code for external C/C++ libraries, and for fast C modules that speed up the execution of Python code.
Note that for one-time builds, e.g. for CI/testing, on platforms that are not covered by one of the wheel packages provided on PyPI and the pure Python wheel that we provide is not used, it is substantially faster than a full source build to install an uncompiled (slower) version of Cython with:
pip install Cython --install-option="--no-cython-compile"
Installing Cython¶
Many scientific Python distributions, such as Anaconda [Anaconda] , Enthought Canopy [Canopy] , and Sage [Sage] , bundle Cython and no setup is needed. Note however that if your distribution ships a version of Cython which is too old you can still use the instructions below to update Cython.
Unlike most Python software, Cython requires a C compiler to be present on the system. The details of getting a C compiler varies according to the system used:
- Linux The GNU C Compiler (gcc) is usually present, or easily available through the package system. On Ubuntu or Debian, for instance, it is part of the build-essential package. Next to a C compiler, Cython requires the Python header files. On Ubuntu or Debian, the command sudo apt-get install build-essential python3-dev will fetch everything you need.
- Mac OS X To retrieve gcc, one option is to install Apple’s XCode, which can be retrieved from the Mac OS X’s install DVDs or from https://developer.apple.com/.
- Windows The CPython project recommends building extension modules (including Cython modules) with the same compiler that Python was built with. This is usually a specific version of Microsoft Visual C/C++ (MSVC) — see https://wiki.python.org/moin/WindowsCompilers. MSVC is the only compiler that Cython is currently tested with on Windows. If you’re having difficulty making setuptools detect MSVC then PyMSVC aims to solve this. A possible alternative is the open source MinGW (a Windows distribution of gcc). See the appendix for instructions for setting up MinGW manually. Enthought Canopy and Python(x,y) bundle MinGW, but some of the configuration steps in the appendix might still be necessary.
The simplest way of installing Cython is by using pip :
The newest Cython release can always be downloaded from https://cython.org/. Unpack the tarball or zip file, enter the directory, and then run:
For one-time builds, e.g. for CI/testing, on platforms that are not covered by one of the wheel packages provided on PyPI, it is substantially faster than a full source build to install an uncompiled (slower) version of Cython with
pip install Cython --install-option="--no-cython-compile"
How To Install cython on Ubuntu 20.04
In this tutorial we learn how to install cython on Ubuntu 20.04.
What is cython
Cython is a language that makes writing C extensions for the Python language as easy as Python itself. Cython is based on the well-known Pyrex, but supports more cutting edge functionality and optimizations.
The Cython language is very close to the Python language, but Cython additionally supports calling C functions and declaring C types on variables and class attributes. This allows the compiler to generate very efficient C code from Cython code.
This makes Cython the ideal language for wrapping external C libraries, and for fast C modules that speed up the execution of Python code. Description-md5: 8c2f4ce3deabcb6941dffa8d5f424759
There are three ways to install cython on Ubuntu 20.04. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.
Install cython Using apt-get
Update apt database with apt-get using the following command.
After updating apt database, We can install cython using apt-get by running the following command:
sudo apt-get -y install cython
Install cython Using apt
Update apt database with apt using the following command.
After updating apt database, We can install cython using apt by running the following command:
sudo apt -y install cython
Install cython Using aptitude
If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.
After updating apt database, We can install cython using aptitude by running the following command:
sudo aptitude -y install cython
How To Uninstall cython on Ubuntu 20.04
To uninstall only the cython package we can use the following command:
sudo apt-get remove cython
Uninstall cython And Its Dependencies
To uninstall cython and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:
sudo apt-get -y autoremove cython
Remove cython Configurations and Data
To remove cython configuration and data from Ubuntu 20.04 we can use the following command:
sudo apt-get -y purge cython
Remove cython configuration, data, and all of its dependencies
We can use the following command to remove cython configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge cython
References
Summary
In this tutorial we learn how to install cython package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.
Installing Cython¶
Many scientific Python distributions, such as Anaconda [Anaconda] , Enthought Canopy [Canopy] , and Sage [Sage] , bundle Cython and no setup is needed. Note however that if your distribution ships a version of Cython which is too old you can still use the instructions below to update Cython.
Unlike most Python software, Cython requires a C compiler to be present on the system. The details of getting a C compiler varies according to the system used:
- Linux The GNU C Compiler (gcc) is usually present, or easily available through the package system. On Ubuntu or Debian, for instance, it is part of the build-essential package. Next to a C compiler, Cython requires the Python header files. On Ubuntu or Debian, the command sudo apt-get install build-essential python3-dev will fetch everything you need.
- Mac OS X To retrieve gcc, one option is to install Apple’s XCode, which can be retrieved from the Mac OS X’s install DVDs or from https://developer.apple.com/.
- Windows The CPython project recommends building extension modules (including Cython modules) with the same compiler that Python was built with. This is usually a specific version of Microsoft Visual C/C++ (MSVC) — see https://wiki.python.org/moin/WindowsCompilers. MSVC is the only compiler that Cython is currently tested with on Windows. If you’re having difficulty making setuptools detect MSVC then PyMSVC aims to solve this. A possible alternative is the open source MinGW (a Windows distribution of gcc). See the appendix for instructions for setting up MinGW manually. Enthought Canopy and Python(x,y) bundle MinGW, but some of the configuration steps in the appendix might still be necessary.
The simplest way of installing Cython is by using pip :
The newest Cython release can always be downloaded from https://cython.org/. Unpack the tarball or zip file, enter the directory, and then run:
For one-time builds, e.g. for CI/testing, on platforms that are not covered by one of the wheel packages provided on PyPI, it is substantially faster than a full source build to install an uncompiled (slower) version of Cython with
pip install Cython --install-option="--no-cython-compile"