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

Материал из WiKi - UserSide
Нет описания правки
Нет описания правки
 
Строка 9: Строка 9:
  sudo apt install -y python3-dev python3-pip python3-venv libffi-dev libssl-dev pkg-config
  sudo apt install -y python3-dev python3-pip python3-venv libffi-dev libssl-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.12.1, it is more reliable to install version 3.11.10, because as soon as a new version (3.12) is released, there is a chance that not all dependent packages support it.
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.13.1, it is more reliable to install version 3.12.8, because as soon as a new version (3.13) 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.
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.10
  PY_VER=3.12.8


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:
Строка 22: Строка 22:
  make -j $(nproc)
  make -j $(nproc)
  sudo -H make altinstall
  sudo -H make altinstall
  curl -sS https://bootstrap.pypa.io/get-pip.py | sudo -H python3.11
  curl -sS https://bootstrap.pypa.io/get-pip.py | sudo -H python3.12
  cd ..
  cd ..
  sudo rm -rf Python-${PY_VER} python.tgz
  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.
After performing all these steps, you will have another version of Python installed on your system. In this case it is Python 3.12 and the pip tool is also version 3.12. 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:
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
  python3.12 --version
  pip3.11 --version
  pip3.12 --version


Now, to create a virtual environment for any module or poller, you need to use the following syntax:
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 python3.12 -m venv venv
  sudo venv/bin/pip install -U pip wheel
  sudo venv/bin/pip install -U pip wheel
  and so on.
  and so on.

Текущая версия от 09:00, 13 декабря 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 libssl-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.13.1, it is more reliable to install version 3.12.8, because as soon as a new version (3.13) 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.12.8

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.12
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.12 and the pip tool is also version 3.12. 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.12 --version
pip3.12 --version

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

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