Debian default python version

Debian default python version

Introduction

Python, the high-level, interactive object oriented language, includes an extensive class library with lots of goodies for network programming, system administration, sounds and graphics. Debian provides the latest stable Python 3 release; it also provides the latest stable Python 2 release, but Python 2 is unsupported by the Python Foundation since 2020-01-01 and is being removed as of Debian 11 (Bullseye). It may also provide additional versions, as well as tons of third party packages. Python is an important part of the Debian ecosystem.

Python is very easy to learn. You can begin with the DebianWomen/PythonTutorial or the official online tutorial if you want to get started programming in Python. You might also be interested in the Python wiki, the Python FAQ, and the online documentation.

Software written in the Python programming language is executed by the Python interpreter. It is usually compiled into platform-independent bytecode files to increase performance. Python compiles and writes bytecode *.pyc files alongside the *.py sources. Extension modules can also be written in C, which are distributed as .so shared libraries.

Читайте также:  До нового года html

Therefore, software written in pure Python can be distributed as source code or as compiled bytecode. The latter is similar to Java.

Python in Debian

Sources available: ssh://git.debian.org//git/git/python-modules/misc/python-debian-artwork.git

As such, with hundreds of Python modules and multiple versions of Python supported, Debian is the largest «integrated Python distribution». Users of other operating systems (e.g. Windows and OS X) can also benefit from this integrative effort by means of virtualization (e.g. see NeuroDebian VM page for easy way to start)

Please also refer to the packaging style guide and Python Packaging wiki pages.

As of 2015-10-09 we now maintain all of our packages in Git. Here is team policy for using git for team packages.

NOTE: Debian 11 (bullseye) has removed the «python» package and the ‘/usr/bin/python’ symlink due to the deprecation of Python 2. No packaged scripts should depend on the existence of ‘/usr/bin/python’: if they do, that is a bug that should be reported to Debian. You can use the ‘python-is-python3’ or ‘python-is-python2’ packages to restore an appropriate ‘/usr/bin/python’ symlink for third-party or legacy scripts. See also Python/FAQ#Python_2_support.

Maintainers

  • cpython-team maintains the Python compiler/interpreter package.
  • Debian Python Team maintains some Python modules and applications.

Supported Python Versions

  • Debian Bookworm currently contains 3.11, and will likely not ship Python 2, see also Python/FAQ#Python_2_support.
  • Debian Bullseye contains 3.9, minimal support for 2.7
  • Debian Buster contains Python 2.7, 3.7
  • Debian Stretch contains Python 2.7, 3.5
  • Debian Jessie contains Python 2.7, 3.4
  • Debian Wheezy contains Python 2.7, 3.2
  • Debian Squeeze contains Python 2.5, 2.6 (the default), 3.1.
  • Debian Lenny contains Python 2.4 and 2.5 (the default).
  • Debian Testing contains some 2.x and 3.x
  • Debian Unstable contains some 2.x and 3.x, python2 is being removed https://wiki.debian.org/Python/2Removal
  • Debian experimental may also contain some (experimental!) packages 2.x and 3.x
  • Distribution(s) shipping python3.11
  • Distribution(s) shipping python3.10
  • Distribution(s) shipping python3.9
  • Distribution(s) shipping python3.8 (none)
  • Distribution(s) shipping python3.7
  • Distribution(s) shipping python3.6 (none)
  • Distribution(s) shipping python3.5
  • Distribution(s) shipping python3.4
  • Distribution(s) shipping python3.3
  • Distribution(s) shipping python3.2
  • Distribution(s) shipping python3.1
  • Distribution(s) shipping python3.0 (none)
  • Distribution(s) shipping python2.7
  • Distribution(s) shipping python2.6
  • Distribution(s) shipping python2.5 (none)
  • Distribution(s) shipping python2.4 (none)

Debian Python Policy for Python developers

The Debian Python Policy describes conventions for packaging and distributing Python code in Debian.

Feel free to ask any questions on debian-python@lists.debian.org mailing list.

If you want to maintain a Python package, you have to know how the Debian Development works.

Deviations from upstream

  • dist-packages instead of site-packages. Third party Python software installed from Debian packages goes into dist-packages, not site-packages. This is to reduce conflict between the system Python, and any from-source Python build you might install manually.
  • The standard profile and pstats modules are not included, due to restrictive redistribution clauses in their license that don’t meet the DFSG. cProfile and hotshot are however included.
  • In Debian 7 (Wheezy), the python-setuptools package installs the Distribute fork instead of the standard setuptools. In Debian 8 (Jessie), we reverted back to the merged setuptools project.
  • Also in Debian 7 (Wheezy), the python-virtualenv also uses distribute by default, but can enable classic setuptools with an optional switch. As above, in Debian 8 (Jessie) this just use the merged setuptools.
  • distutils setup scripts install files in /usr/local/ not sys.prefix (which is normally /usr/). This is because /usr/ is reserved for files installed from Debian packages. Note that /usr/local/lib/pythonX.Y/dist-packages is in sys.path so that modules not installed from Debian packages can still be accessed by the system Python. Tools like debhelper pass the --install-layout=deb option to the setup script while building a Debian package so that its installs files into /usr/ not /usr/local/.
  • Python 2.7, 3.3, and 3.4 are multiarch aware.

Encouraged practices

  • Style guide for packaging Python libraries (includes adding Python 3 support)
  • Style guide for packaging Python applications (includes Python 3 support)
  • There is a growing number of python-*-dbg packages for modules with extensions. They provide extensions built using python*-dbg libraries allowing to take advantage of GDB constantly improving support for debugging of Python modules and extensions. If you build extensions module, please provide corresponding -dbg package
  • Converting your package to dh_python2

Installing from Source

If you want the latest version, or a development version of Python, you will likely need to install it from source. In order to do that, first make sure you have build dependencies. As root, run: «aptitude build-dep python3»

Pick your version and download the «Gzipped source tarball» of the version of your choice from Python download page. Once you have the archive, extract it using «tar -xvf Python-.tgz». Once that is done, go to that directory with «cd Python-» and use the following command to compile Python from source: «./configure && make && make test» (as regular user). To install it globally without damaging system Python installed with APT, use the altinstall target (as root): «make altinstall».

See also

Источник

How to Change from Default to Alternative Python Version on Debian

Python is an important programming language for all Linux-based distributions. This is the reason why you will find Python preinstalled in the system with the default version. The case may occur when you require switching from the default Python version to an alternative one if installed. The fact is some applications require different Python versions.

This tutorial will demonstrate the procedure of changing the default to an alternative Python version on Debian Linux.

How to Check the Current Version of the Default Python on Debian Linux

Before moving toward changing the default Python version to an alternative one, it’s important for you to find out the versions of Python installed on your system. The default directory for Python in Debian or another Linux-based system is “/usr/bin/python”. Using the list command “ls”, you can find the installed Python versions on your system.

Note: The output may be different in your case.

To check the current version of the default Python on the Debian, execute the following command:

In our case, the current version of the default Python is 2.7.18. It could be different in your case depending on the system you are using.

How to Change from Default to Alternative Python Version on Debian Linux

There are two ways to change from the default to alternative Python version on Debian Linux:

Method 1: Change From Default to Alternative Python Version Through update-alternatives Command

First, the user must create a symlink between the different python version directories separately so that they all can be merged in a group named “python”. Since Python version 3.9 is the alternative version, we are going to use, therefore, we must create a symlink of Python version 3.9 via the below-given command:

Next, create a symlink of Python version 2.7 18 by running the below command:

Once the symlinks are created, you can list the installed Python versions to switch them and for that, run the following command:

There you will see the Python version and by default 2.7 is selected. You can enter any number of your choice, to set it as the default version of your system. For example, I am entering the 2 to choose python3.9:

Once you switch to the Python version, run the Python version command to verify it:

Method 2: Change from Default Python to Alternative Python Through pyenv Tool

You can also change the default Python to alternative using pyenv using the following steps:

Step 1: First update the system and run the following command to ensure there are no unmet system dependencies:

sudo apt-get update ; sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev git wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Step 2: Once done, run the pyenv installation script on Debian via the below-given command:

Step 3: Next, open the source file of an environmental variable through the below-mentioned command:

Add the following script at the bottom of the source file and save the file by pressing ctrl + X and then Y:

export PYENV_ROOT = «$HOME/.pyenv»

command -v pyenv > /dev/null || export PATH = «$PYENV_ROOT/bin:$PATH»

Step 4: Reload the changes to an environment variable through the following command:

Step 5: Verify the installation of pyenv through the version command:

Step 6: Run the list command to check the available Python versions:

Step 7: You can pick any version you want to install on Debian, I am choosing the 3.10.9

Step 8: After installing run the following command to make the installed version global for all users:

Run the following command to confirm the changes:

Bottom Line

You can install multiple Python versions on Debian and easily switch between them. There is no need to remove one Python version to install another because you can use them concurrently. You must create a symlink for the Python version in a group and after that, you can switch to any Python version you want using the “–update alternative” command.

About the author

Zainab Rehman

I’m an author by profession. My interest in the internet world motivates me to write for Linux Hint and I’m here to share my knowledge with others.

Источник

Оцените статью