Annexes:Python
Révision datée du 10 février 2025 à 12:12 par Admin (discussion | contributions) (→Test de fonctionnement)
Sommaire
[masquer]Généralités
Limites de cette section
Cette section n’a pas la prétention de traiter tous les cas possibles d'installation de Python …
Le principe est d'avoir la bonne version et ses dépendances pour le module SQWarePredict.
Avant de vous lancer dans l’installation, vous devez d'abord avoir la version de dbSQWare avec SQWarePredict (v2025.01 mini) pour avoir les dépendances.
Principe
Nous allons :
- Installer Python-3.12.8
- Configurer l'environnement
- Installer les dépendances
- Paramétrer et tester SQWarePredict
Installation
Installation de Python-3.12.8
Téléchargez les sources et mettez-les dans /tmp :
# Install Python-3.12.8 # https://www.python.org/ftp/python/3.12.8/Python-3.12.8.tgz
1 # From : dbsqware@vmsqwarebox
2
3 mkdir /home/dbsqware/dbSQWare/SQWarePredict/python-src
4 mkdir -p /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8
5 cd /home/dbsqware/dbSQWare/SQWarePredict/python-src
6 tar -xzvf /tmp/Python-3.12.8.tgz
7 cd Python-3.12.8
8
9 # configure, dest => /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8
10 ./configure --prefix=/home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8 --enable-optimizations
checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for python3.9... python3.9 checking for --enable-universalsdk... no checking for --with-universal-archs... no ...
1 # compil
2 make
Running code to generate profile data (this can take a while): # First, we need to create a clean build with profile generation # enabled. make profile-gen-stamp make[1]: Entering directory '/home/dbsqware/dbSQWare/SQWarePredict/python-src/Python-3.12.8' make clean make[2]: Entering directory '/home/dbsqware/dbSQWare/SQWarePredict/python-src/Python-3.12.8' find . -depth -name '__pycache__' -exec rm -rf {} ';' ...
1 # install
2 make install
Creating directory /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/bin Creating directory /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/lib if test "no-framework" = "no-framework" ; then \ /usr/bin/install -c python /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/bin/python3.9; \ ... ... Installing collected packages: setuptools, pip WARNING: The scripts pip3 and pip3.9 are installed in '/home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed pip-23.0.1 setuptools-58.1.0
1 # creation des liens python et pip
2 cd /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/bin
3 ln -s python3 python
4 ln -s pip3 pip
Mise à jour de l'environnement
Dans le ~dbsqware/.bash_profile
1 # env Python 3.12.8 (pour SQWarePredict)
2 export PATH=/home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/bin:$PATH
3 export LD_LIBRARY_PATH=/home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/lib:$LD_LIBRARY_PATH
1 # vérification du PATH
2
3 dbsqware@vmsqwarebox:/home/dbsqware $ type python
4 python is /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/bin/python
5
6 dbsqware@vmsqwarebox:/home/dbsqware $ type pip
7 pip is /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/bin/pip
1 # vérification des versions
2
3 dbsqware@vmsqwarebox:/home/dbsqware $ python --version
4 Python 3.12.8
5
6 dbsqware@vmsqwarebox:/home/dbsqware $ pip --version
7 pip 24.3.1 from /home/dbsqware/dbSQWare/SQWarePredict/python/3.12.8/lib/python3.12/site-packages/pip (python 3.12)
1 ## Mise en place de l'env Python
2 python -m venv /home/dbsqware/dbSQWare/SQWarePredict/python/SQWarePredict-python-env-3.12.8
3 cd /home/dbsqware/dbSQWare/SQWarePredict/python
4 ll SQWarePredict-python-env-3.12.8
5 ln -s SQWarePredict-python-env-3.12.8 SQWarePredict-python-env
6 . /home/dbsqware/dbSQWare/SQWarePredict/python/SQWarePredict-python-env/bin/activate
1 dbsqware@vmsqwarebox:/home/dbsqware $ type python
2 python is /home/dbsqware/dbSQWare/SQWarePredict/python/SQWarePredict-python-env-3.12.8/bin/python
3
4 dbsqware@vmsqwarebox:/home/dbsqware $ type pip
5 pip is /home/dbsqware/dbSQWare/SQWarePredict/python/SQWarePredict-python-env-3.12.8/bin/pip
6
7 dbsqware@vmsqwarebox:/home/dbsqware $ python --version
8 Python 3.12.8
9
10 dbsqware@vmsqwarebox:/home/dbsqware $ pip --version
11 pip 24.3.1 from /home/dbsqware/dbSQWare/SQWarePredict/python/SQWarePredict-python-env-3.12.8/lib/python3.12/site-packages/pip (python 3.12)
1 (SQWarePredict-python-env-3.12.8) dbsqware@srvdbsqware04:/home/dbsqware $ pip list
2
3 Package Version
4 ------- -------
5 pip 24.3.1
Installation des dépendances
Attention, il faut avoir activé l'environnement "SQWarePredict-python-env" !
1 # Dépendances pip
2 (SQWarePredict-python-env-3.12.8) dbsqware@srvdbsqware04:/home/dbsqware/dbSQWare/SQWarePredict/python $ pip install --upgrade pip setuptools wheel
Requirement already satisfied: pip in ./SQWarePredict-python-env-3.12.8/lib/python3.12/site-packages (24.3.1) Collecting setuptools Downloading setuptools-75.8.0-py3-none-any.whl.metadata (6.7 kB) Collecting wheel Downloading wheel-0.45.1-py3-none-any.whl.metadata (2.3 kB) Downloading setuptools-75.8.0-py3-none-any.whl (1.2 MB) ???????????????????????????????????????? 1.2/1.2 MB 14.4 MB/s eta 0:00:00 Downloading wheel-0.45.1-py3-none-any.whl (72 kB) Installing collected packages: wheel, setuptools Successfully installed setuptools-75.8.0 wheel-0.45.1
1 # Install dependances
2 cd /home/dbsqware/dbSQWare/SQWarePredict/engine/
3 pip install .
Processing /home/dbsqware/dbSQWare/SQWarePredict/engine Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting contourpy==1.3.1 (from SQWarePredict==1.0) .... .... Stored in directory: /tmp/pip-ephem-wheel-cache-l9urxsek/wheels/fb/0f/e3/8209d088cd9c825dd311fd9cbf83a320192744186bdc99b5ec Successfully built SQWarePredict Installing collected packages: pytz, tzdata, toml, six, python-dotenv, pyparsing, pillow, packaging, numpy, mysql-connector-python, kiwisolver, fonttools, cycler, scipy, python-dateutil, patsy, contourpy, pandas, matplotlib, statsmodels, seaborn, SQWarePredict Successfully installed SQWarePredict-1.0 contourpy-1.3.1 cycler-0.12.1 fonttools-4.55.3 kiwisolver-1.4.8 matplotlib-3.10.0 mysql-connector-python-9.1.0 numpy-2.2.1 packaging-24.2 pandas-2.2.3 patsy-1.0.1 pillow-11.1.0 pyparsing-3.2.1 python-dateutil-2.9.0.post0 python-dotenv-1.0.1 pytz-2024.2 scipy-1.15.0 seaborn-0.13.2 six-1.17.0 statsmodels-0.14.4 toml-0.10.2 tzdata-2024.2
1 # Check des dépendances
2 pip list
Package Version ---------------------- ----------- contourpy 1.3.1 cycler 0.12.1 fonttools 4.55.3 kiwisolver 1.4.8 matplotlib 3.10.0 mysql-connector-python 9.1.0 numpy 2.2.1 packaging 24.2 pandas 2.2.3 patsy 1.0.1 pillow 11.1.0 pip 24.3.1 pyparsing 3.2.1 python-dateutil 2.9.0.post0 python-dotenv 1.0.1 pytz 2024.2 scipy 1.15.0 seaborn 0.13.2 setuptools 75.8.0 six 1.17.0 SQWarePredict 1.0 statsmodels 0.14.4 toml 0.10.2 tzdata 2024.2 wheel 0.45.1
Paramétrer et tester SQWarePredict
paramétrage de SQWarePredict
1 # Paramétrage des accès à la db (vous pouvez créer un nouveau compte ou utiliser celui de SQWareCentral !)
2 cd /home/dbsqware/dbSQWare/SQWarePredict/engine
3 cat sqwarepredict.ini
# Credentials for SQWarePredict [db] MysqlHost="localhost" MysqlUser="sqware_predict" MysqlPass="SQWarePredict1234." MysqlDb="dbsqware_db" MysqlPort=3306
Test de fonctionnement
1 # Activation de l'env et test de 'Predict'
2 . /home/dbsqware/dbSQWare/SQWarePredict/python/SQWarePredict-python-env/bin/activate
3 cd /home/dbsqware/dbSQWare/SQWarePredict/engine
4 python -m bin.predict -i sql -f /home/dbsqware/dbSQWare/SQWarePredict/param/generic/InstanceGrowth_size.ini -l Instance=SQWareCentral NbMonth=24 -m 6