Python-update EN: различия между версиями

Материал из WiKi - UserSide
Нет описания правки
Нет описания правки
Строка 13: Строка 13:
Next, you need to create a temporary environment variable whose value will contain the version number of the Python version you are going to install.
Next, you need to create a temporary environment variable whose value will contain the version number of the Python version you are going to install.


  PY_VER=3.11.7
  PY_VER=3.11.9


The following are commands that you simply execute one at a time, one after the other, to control the process and in case of error not to execute the rest of the commands. Copy one line at a time and execute:
The following are commands that you simply execute one at a time, one after the other, to control the process and in case of error not to execute the rest of the commands. Copy one line at a time and execute:

Версия от 09:27, 14 апреля 2024

en | ru

If the version of Python installed on your OS is not supported by modules or poller, you must install an additional new version of Python that meets all requirements.

Important: Changing the system version of Python to the new version is not recommended! The only correct way is to install the new version in parallel with the system version. Otherwise, various system services and utilities that use Python may stop working.

First make sure you have all the necessary global packages installed in Python, which are needed globally to run the virtual environment, to build other dependencies.

sudo apt install -y python3-dev python3-pip python3-venv libffi-dev pkg-config

Once everything is installed, go to https://www.python.org/downloads/source/ and copy the latest version number of the current branch, or the previous version if the current branch is too recent. For example, if the latest version is 3.11.1, it is more reliable to install version 3.10.11, because as soon as a new version (3.11) is released, there is a chance that not all dependent packages support it.

Next, you need to create a temporary environment variable whose value will contain the version number of the Python version you are going to install.

PY_VER=3.11.9

The following are commands that you simply execute one at a time, one after the other, to control the process and in case of error not to execute the rest of the commands. Copy one line at a time and execute:

curl -o python.tgz "https://www.python.org/ftp/python/${PY_VER}/Python-${PY_VER}.tgz"
tar xzf python.tgz
cd Python-${PY_VER}
./configure --enable-optimizations
make -j $(nproc)
sudo -H make altinstall
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo -H python3.11
cd ..
sudo rm -rf Python-${PY_VER} python.tgz

After performing all these steps, you will have another version of Python installed on your system. In this case it is Python 3.11 and the pip tool is also version 3.11. The system version of Python will not be changed and we do not recommend changing it, as some system components may be dependent on it.

To use this particular version of python and pip, you need to specify the entire names of the files you run. For example:

python3.11 --version
pip3.11 --version

Now, to create a virtual environment for any module or poller, you need to use the following syntax:

sudo python3.11 -m venv venv
sudo venv/bin/pip install -U pip wheel
and so on.