synOCR SUCHE HILFE: Installation des Python Moduls pymupdf auf aarch64

geimist

Benutzer
Sehr erfahren
Maintainer
Registriert
04. Jan. 2012
Beiträge
5.719
Reaktionspunkte
1.526
Punkte
234
Hallo zusammen,

mangels eigener Hardware suche ich jemand, der mich dabei unterstützt, synOCR v1.5 auch auf ARM64-CPUs installieren zu können.

In synOCR werden alle Python Module in einer virtuellen Umgebung installiert. Auf aarch64 sieht die Fehlermeldung derzeit offensichtlich so aus:
Code:
 error: subprocess-exited-with-error
 
  × Building wheel for pymupdf (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error: command '/usr/local/aarch64-unknown-linux-gnu/bin/ccache/aarch64-unknown-linux-gnu-wrap-gcc' failed: No such file or directory
      [end of output]
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pymupdf
ERROR: Failed to build installable wheels for some pyproject.toml based projects (pymupdf)
ERROR at line 2868: prepare_python_log=$(prepare_python)
check if aarch64 has at least Python 3.9 installed ➜ ERROR at line 1192: IFS='
' read -d '' -ra python_versions <<< "$(find /bin /usr/bin /usr/local/bin -maxdepth 1 -name 'python3.*')"
Python 3.9 or higher found: 3.9
                  pip already installed (pip 22.0.4 from /usr/syno/synoman/webman/3rdparty/synOCR/python3_env/lib/python3.9/site-packages/pip (python 3.9)) / upgrade available ...
                  Requirement already satisfied: pip in ./python3_env/lib/python3.9/site-packages (22.0.4)
                  Collecting pip
                    Downloading pip-25.0.1-py3-none-any.whl (1.8 MB)
                       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 5.1 MB/s eta 0:00:00
                  Installing collected packages: pip
                    Attempting uninstall: pip
                      Found existing installation: pip 22.0.4
                      Uninstalling pip-22.0.4:
                        Successfully uninstalled pip-22.0.4
                  Successfully installed pip-25.0.1

                ➜ check python module "DateTime": ➜ DateTime was not found and will be installed ➜ ok
                ➜ check python module "dateparser": ➜ dateparser was not found and will be installed ➜ ok
                ➜ check python module "pypdf==3.5.1": ➜ pypdf==3.5.1 was not found and will be installed ➜ ok
                ➜ check python module "pikepdf==7.1.2": ➜ pikepdf==7.1.2 was not found and will be installed ➜ ok
                ➜ check python module "Pillow": ➜ Pillow was not found and will be installed ➜ ok
                ➜ check python module "yq": ➜ yq was not found and will be installed ➜ ok
                ➜ check python module "PyYAML": ➜ PyYAML was not found and will be installed ➜ ok
                ➜ check python module "apprise==1.9.2": ➜ apprise==1.9.2 was not found and will be installed ➜ ok
                ➜ check python module "pymupdf==1.18.6": ➜ pymupdf==1.18.6 was not found and will be installed ➜ ERROR at line 1297: tmp_log1=$(python3 -m pip install "${module}")
failed ! ! ! (please install pymupdf==1.18.6 manually)
                  install log:
                  Collecting pymupdf==1.18.6
                    Downloading PyMuPDF-1.18.6.tar.gz (258 kB)
                    Installing build dependencies: started
                    Installing build dependencies: finished with status 'done'
                    Getting requirements to build wheel: started
                    Getting requirements to build wheel: finished with status 'done'
                    Preparing metadata (pyproject.toml): started
                    Preparing metadata (pyproject.toml): finished with status 'done'
                  Building wheels for collected packages: pymupdf
                    Building wheel for pymupdf (pyproject.toml): started
                    Building wheel for pymupdf (pyproject.toml): finished with status 'error'
                  Failed to build pymupdf
                  ERROR at line 1297: python3 -m pip install "${module}"
ERROR at line 2868: return 1
                prepare_python: ! ! ! ERROR ! ! !

Wie man sieht, gibt es Schwierigkeiten bei der Installation von pymupdf. Hast du die Möglichkeit, die nachstehende Funktion auf deinem Gerät lauffähig zu machen?
Als Voraussetzung gilt, das mindestens Python 3.9 installiert ist. Möglicherweise klappt es ja mit einer neueren Version als pymupdf==1.18.6. Dann müsste ich zwar ein paar Funktionen umbauen, sollte sich aber lohnen.

Du brauchst keine Sorge haben, das dadurch etwas im DSM installiert wird. Die virtuelle Pythonumgebung wird in einem Ordner des gleichen Verzeichnisses installiert, in das du das Skript speicherst und startest. Um die Installation rückgängig zu machen, muss lediglich das Verzeichnis gelöscht werden.

Vielen Dank für deine Unterstützung :love:

Hier das Skript (anbei auch als zip):
Bash:
#!/bin/bash
# /volume3/DEV/synOCR_python3_env.sh


    python3_env="${0%/*}/synOCR_python3_env"
    python_check=ok             # will be set to failed if the test fails
    synOCR_python_module_list=( DateTime dateparser "pypdf==3.5.1" "pikepdf==7.1.2" Pillow yq PyYAML "apprise==1.9.2" "pymupdf==1.18.6" "numpy==1.19.5" )
    machinetyp=$(uname --machine)

prepare_python()
{
#########################################################################################
# This function check the python3 & pip installation and the necessary modules          #
#                                                                                       #
#########################################################################################

python_path=""

# check python for aarch64:
# ---------------------------------------------------------------------
# Reason for the check: dateparser cannot be installed due to an incompatibility of the backports.zoneinfo dependency. This dependency no longer exists as of Python3.9
if [ "${machinetyp}" = aarch64 ]; then
    echo -n "check if aarch64 has at least Python 3.9 installed ➜ "
    # Search for available Python versions and store them in an array
    IFS=$'\n' read -d '' -ra python_versions <<< "$(find /bin /usr/bin /usr/local/bin -maxdepth 1 -name 'python3.*')" ; IFS="${IFSsaved}"

    # Loop over the found versions to determine the latest version
    latest_py_version="3.8"
    for py_interpreter in "${python_versions[@]}"; do
        # Extract the version number from the interpreter:
        py_version=$("${py_interpreter}" -c "import sys; print('.'.join(map(str, sys.version_info[:2])))" )

        # Compare the version with the highest version so far
        if [[ "${py_version}" > "${latest_py_version}" ]]; then
            # Check if this version is 3.9 or higher by reading it from the interpreter
            latest_py_version="${py_version}"
            python_path="${py_interpreter}"
        fi
    done

    # Check if a suitable version was found
    if [ "${latest_py_version}" != "3.8" ]; then
        echo "Python 3.9 or higher found: ${latest_py_version}"
    else
        echo "No suitable Python version (>=3.9) found. Please install at least Python 3.9"
        exit 1
    fi
else
    python_path="$(which python3)"
fi

# Does the virtual Python environment match the chosen interpreter? Otherwise delete the environment:
# ---------------------------------------------------------------------
if [ -d "${python3_env}" ]; then
    local python_env_path=${python3_env}/bin/python3
    local env_version
    local py_version
    env_version=$("${python_env_path}" -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
    py_version=$("${python_path}" -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
    # Compare the version with the highest version so far
    if [[ "${env_version}" != "${py_version}" ]]; then
        echo "the virtual Python environment does not match the selected interpreter and is therefore deleted"
        rm -r "${python3_env}"
    fi
fi

# check python3 environment:
# ---------------------------------------------------------------------
    printf "\n%s\n" "Check Python:"
    if [ -z "${python_path}" ]; then
        echo "(Python3 is not installed / use fallback search with regex"
        echo "for more precise search results Python3 is required)"
        python_check=failed
        return 1
    else
        [ ! -d "${python3_env}" ] && "${python_path}" -m venv "${python3_env}"
        source "${python3_env}/bin/activate"

        printf "%s\n" "python3 already installed (${python_path})"

        # check / install pip:
        # ---------------------------------------------------------------------
            printf "\n%s\n" "Check pip: "
            if ! python3 -m pip --version > /dev/null  2>&1 ; then
                printf "%s" "Python3 pip was not found and will be now installed ➜ "
                # install pip:
                tmp_log1=$(python3 -m ensurepip --default-pip)
                # upgrade pip:
                tmp_log2=$(python3 -m pip install --upgrade pip)
                # check install:
                if python3 -m pip --version > /dev/null  2>&1 ; then
                    echo "ok"
                else
                    echo "failed ! ! ! (please install Python3 pip manually)"
                    echo "  install log:"
                    echo "${tmp_log1}"
                    echo "${tmp_log2}"
                    python_check=failed
                    return 1
                fi
            else
                if python3 -m pip list 2>&1 | grep -q "version.*is available" ; then
                    printf "%s\n" "  pip already installed ($(python3 -m pip --version)) / upgrade available ..."
                    python3 -m pip install --upgrade pip
                else
                    printf "%s\n" "  pip already installed ($(python3 -m pip --version))"
                fi
            fi

            printf "\n%s\n" "  read installed python modules:"

            moduleList=$(python3 -m pip list 2>/dev/null)
            echo "${moduleList}"

            # check / install python modules:
            # ---------------------------------------------------------------------
            echo -e
            for module in "${synOCR_python_module_list[@]}"; do
                moduleName=$(echo "${module}" | awk -F'=' '{print $1}' )

                unset tmp_log1
                printf "%s" "➜ check python module \"${module}\": ➜ "
                if !  grep -qi "${moduleName}" <<<"${moduleList}"; then
                    printf "%s" "${module} was not found and will be installed ➜ "

                    # install module:
                    tmp_log1=$(python3 -m pip install "${module}")

                    # check install:
                    if grep -qi "${moduleName}" <<<"$(python3 -m pip list 2>/dev/null)" ; then
                        echo "ok"
                    else
                        echo "failed ! ! ! (please install ${module} manually)"
                        echo "  install log:" && echo "${tmp_log1}"
                        python_check=failed
                        return 1
                    fi
                else
                    printf "ok\n"
                fi
            done

            if [ "${python_check}" = ok ]; then
                echo "${local_version}" > "${python3_env}/synOCR_python_env_version"
            else
                echo "0" > "${python3_env}/synOCR_python_env_version"
            fi

            printf "\n"
    fi

    printf "\n%s\n" "  module list:" && python3 -m pip list && printf "\n"

    return 0
}

prepare_python

echo "python_check ➜ $python_check"
 

Anhänge

Additional post fields

 

Kaffeautomat

Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.

Als Dankeschön schalten wir deinen Account werbefrei.

:coffee:

Hier gehts zum Kaffeeautomat