Update Python and Django

Update Python and Django

Windows

1. Back up OMFLOW

Disable and back up OMFLOW. Please see the [Backup and Restore] chapter for details on the backup method.

2. Confirm the current python package

  1. Execute command line as "system administrator"

  2. Switch to the Python folder of omflow

cd "C:\Program Files\OMFLOW Server\Python"
  1. List all current packages (please record the package list yourself)

python.exe -m pip freeze
  1. Command line leaves the current directory

cd..
  1. Change the name of the Python folder to "Python_backup"

3. Install a new version of Python

  1. Download Python3.x (32 Bit) Windows Installer and execute

  2. Select Customize installation custom installation path

  3. Select the installation path C:\PROGRA\~1\OMFLOW Server\Python

4. Install python package

For offline environment, please refer to the subsequent "Supplementary" chapter

  1. Switch back to the Python directory using the command line

cd "C:\Program Files\OMFLOW Server\Python"
  1. Start installing the required packages (all packages listed in Chapter 2.3)

python.exe -m pip install <package name>

5. Modify httpd.conf

Open C:\Program Files\OMFLOW Server\Apache24\conf\httpd.conf, and modify the following two lines of information, change python37 and mod_wsgi.cp37 to the new version number

LoadFile "C:\Program Files\OMFLOW Server\Python\python37.dll"
LoadModule wsgi_module "C:\Program Files\OMFLOW Server\Python\lib\site-packages\mod_wsgi\server\mod_wsgi.cp37-win32.pyd"

6. Modify customized content

python 3.7 => 3.11 Django 2.2 => 4.2

The content of this section uses the above environment as an example. For other modifications required for this version, please check the official Python or Django websites by yourself.

  1. Open C:\Program Files\OMFLOW Server\omflow\omcustom\urls.py

  2. Delete the following line

from django.conf.urls import url
  1. Modify the following line and change all url() in the text to re_path()

#old
from django.urls import path
#Change to
from django.urls import path, re_path
  1. Save and close the file after modifications are completed

7. Restart OMFLOW

Restart the omflow service

Linux

1. Back up OMFLOW

Please back up OMFLOW first. Please refer to the [Backup and Restore] chapter for details on the backup method.

2. Stop OMFLOW

omflow_server stop

3. Delete the python folder under the /opt/omflow folder

rm -rf /opt/omflow/python/

4. Install ubuntu package

Kit list

  • python 3.x *python3.x-dev

  • python3.x-venv *python3-pip

Installation method one: Online installation version (requires Internet connection)

# Update package library
apt-get update -y
# Add package library
add-apt-repository ppa:deadsnakes/ppa -y
# Update package library
apt-get update -y

# Install python3.x and related packages
apt-get install -y python3.x python3.x-dev python3.x-venv python3-pip

Installation method two: no network environment, offline installation method, please see the supplement

Download Ubuntu package offline installation package Install Ubuntu packages offline

5. Set python 3.x as an environment variable (so that python3.x can be called with the command python3)

update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.x 1

6. Create a virtual environment for python 3.x under the /opt/omflow folder

python3 -m venv /opt/omflow/python

7. Enter the virtual environment and install the python package

python package list

  • wheel *django==4.2 *ldap3

  • mod_wsgi

  • openpyxl

  • python package used by DB

  • Other packages that will be used... *Online installation version (requires Internet connection)

# Enter the virtual environment
source /opt/omflow/python/bin/activate

# Install wheel
pip install wheel

# Omit if not necessary
python /usr/lib/python3.11/test/libregrtest/setup.py bdist_wheel

# Install necessary packages. Please evaluate and install other packages by yourself.
pip install django==4.2 ldap3 mod_wsgi openpyxl

For non-network environment and offline installation methods, please see the supplement.

Download the python suite offline installation package (.whl) Install python package offline

8. Modify the wsgi_module path in apache http.conf to a new path

# Modify django.conf
vim /etc/apache2/sites-enabled/django.conf

# Modify the path of wsgi_module

Replenish:

All instructions in this chapter are based on python3.11. Please modify them for different versions.

Download Ubuntu package offline installation package

Find an Ubuntu with the same environment as OMFLOW server, and an Internet connection is required.

Kit required:

*python3.11 *python3.11-dev *python3.11-venv *python3-pip

Download instructions:

# Switch root identity
sudo su

# Add new kit library **deadsnakes** PPA
add-apt-repository ppa:deadsnakes/ppa

# Update package list:
apt-get update

# (If necessary) Clean up the default download folder
apt-get clean

# Download but do not install the package
apt-get install --download-only python3.11 python3.11-dev python3.11-venv python3-pip

The downloaded installation package will be saved in the /var/cache/apt/archives/ directory. You can use FTP software to take it out and put it into the OMFLOW server environment.

Install Ubuntu package offline

Kit required:

*python3.11 *python3.11-dev *python3.11-venv *python3-pip

Copy the .deb file to a directory in Ubuntu, use **/tmp/Downloads** as an example

Ubuntu instructions:

# Switch root identity
sudo su

# Move to the path where the installation package is located
cd /tmp/Downloads

# Use dpkg to install the downloaded package
dpkg -i *.deb

Export a list of installed python packages from an existing environment

If you already have the package list used by the original OMFLOW, you can skip this step.

Reference: https://pip.pypa.io/en/stable/cli/pip_freeze/

Export instructions:

# Switch to the virtual environment of OMFLOW
source /opt/omflow/python/bin/activate

# Export the python package list to /tmp
pip freeze > /tmp/requirements.txt

# Change the django version to version 4.2 or above
vim /tmp/requirements.txt

Use FTP software to take it out and put it in an Ubuntu environment with Internet access, as a reference for subsequent package downloads.

Download the python suite offline installation package (.whl)

Please prepare an environment with python3.11 installed so that you can download the package version suitable for python3.11. This environment must be connected to the Internet.

Download instructions:

# Add a new folder to store offline installation packages
mkdir /tmp/python_package
cd /tmp/python_package

# [Method 1] Use requirements.txt to download in batches
# Assume that you have placed the requirements.txt in the previous step under /tmp/
pip -m install /tmp/requirements.txt

# [Method 2] Manually enter the package name to download
pip -m install <package name>

# After downloading, check how many .whl installation files are in the folder
ll

Use FTP software to take it out and put it back into the OMFLOW server.

Supplement: mod_wsgi will get tar.gz, and the installation method is rather special. Please see offline installation of mod_wsgi.

Install python package offline

Assume that the offline installation package (.whl) of the python package is placed under this path **/opt/omflow/tmp**

Installation instructions:

# Switch to the virtual environment of OMFLOW
source /opt/omflow/python/bin/activate

# Switch to the file path of the offline installation package
cd /opt/omflow/tmp

# Install all whl
pip install *.whl

Install mod_wsgi offline

Installation instructions:

# Switch to the virtual environment of OMFLOW
source /opt/omflow/python/bin/activate

# Decompress tar.gz of mod_wsgi
tar zxvf <mod_wsgi file path>

cd <mod_wsgi decompressed path>

#Easy installation mod_wsgi
python setup.py install

Error handling

If the service cannot be started after updating OMFLOW, please restore OMFLOW according to the [Backup and Restore] chapter, and then perform the update steps again.

Last updated