Installing Python packages (Offline mode)
Use the following steps to install Python in an offline mode environment.
You must download the packages by using an internet-enabled computer, and then transfer the files to the offline computer. The internet-enabled computer must have Python 3.5.2 and the Python package manager Pip installed.
Procedure
- On the online computer, verify if Python and Pip are installed.
Use the which python command to identify the installed versions of Python. The command returns the location of the installed instances. If Python 3.5 is not displayed in the results, go to the Python location and verify the version. For example:
python -V/usr/bin/python -V/usr/local/bin/python3.5 -VIf Python 3.5.2 is not displayed, then you must install it.
Also, the Python packages must be loaded in a specific order to avoid problems with conflicting dependencies. The preliminary packages are downloaded to pre_pythoninstall, and all the rest are downloaded to pythoninstall.
If Python 3.5 and Pip are installed, you can skip steps 2 - 3.
- Install Python on the online computer.
- Log in as the root user, and run the following commands:
mkdir -p /home/sifsuser/pythoninstallyum -y install dos2unixyum -y install yum-utilsyum -y install openssl openssl-develyum -y install gcc sqlite-devel bzip2 bzip2-devel gcc-c++ - Download and extract Python 3.5.2.
cd /home/sifsuser/pythoninstallwget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgztar -xvzf /home/sifsuser/pythoninstall/Python-3.5.2.tgz - Install Python.
cd /home/sifsuser/pythoninstall/Python-3.5.2./configuremakemake altinstall/usr/local/bin/python3.5 -VThe results should show Python 3.5.2.
- Log in as the root user, and run the following commands:
- Install the Python package installer on the online computer.
- Download and install the Python package installer as the root
user.
cd /home/sifsuser/pythoninstallwget https://files.pythonhosted.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl -O /home/sifsuser/pythoninstall/pip-9.0.1-py2.py3-none-any.whl/usr/local/bin/python3.5 /home/sifsuser/pythoninstall/pip-9.0.1-py2.py3-none-any.whl/pip install --no-index --find-links=/home/sifsuser/pythoninstall/ pip-9.0.1-py2.py3-none-any.whlThe results should show
Successfully installed pip-9.0.1
. - Enter the following command to verify the version:
pip3.5 --versionThe result should display a Pip version that is equal to or greater than 9.0.1. You can ignore any update messages.
- Download and install the Python package installer as the root
user.
- Download the prerequisite packages on the online computer.
Log in as the root user, and run the following commands:
cd /home/sifsuser/pre_pythoninstall/usr/local/bin/pip3.5 download -d /home/sifsuser/pre_pythoninstall/ numpy==1.12.1/usr/local/bin/pip3.5 download -d /home/sifsuser/pre_pythoninstall/ h5py==2.7.0/usr/local/bin/pip3.5 download -d /home/sifsuser/pre_pythoninstall/ keras==2.0.2/usr/local/bin/pip3.5 download -d /home/sifsuser/pre_pythoninstall/ scipy==1.0.1/usr/local/bin/pip3.5 download -d /home/sifsuser/pre_pythoninstall/ pyyaml==3.12/usr/local/bin/pip3.5 download -d /home/sifsuser/pre_pythoninstall/ six==1.11.0cd /home/sifsusertar -czvf pre_pythoninstall.tar.gz pre_pythoninstall - Download the main packages on the online computer.
Log in as the root user, and run the following commands:
cd /home/sifsuser/pythoninstallyumdownloader dos2unix yum-utils openssl openssl-devel gcc sqlite-devel bzip2 bzip2-devel gcc-c++ --destdir /home/sifsuser/pythoninstall/ --resolvewget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz -P /home/sifsuser/pythoninstallwget https://github.com/pgmpy/pgmpy/archive/dev.zip -O /home/sifsuser/pythoninstall/dev.zipwget https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz -O /home/sifsuser/pythoninstall/en_core_web_sm-2.0.0.tar.gz/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ beautifulsoup4==4.5.1/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ email_reply_parser==0.5.9/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ flask_cors==3.0.3/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ flask_restful==0.3.6/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ flask==0.12.2/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ gnip_trend_detection==0.5/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ hdfs==2.1.0/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ ibm_db==2.0.8a/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ nltk==3.2.4/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ pandas==0.18.1/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ pypandoc==1.4/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ pyspark==2.3.1/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ requests==2.19.1/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ requests-kerberos==0.12.0/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ scikit-learn==0.18.1/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ segtok==1.5.6/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ spacy==2.0.5/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ statsmodels==0.8.0/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ tensorflow==1.8.0/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ textacy==0.4.1/usr/local/bin/pip3.5 download -d /home/sifsuser/pythoninstall/ wrapt==1.10.11cd /home/sifsuser/tar -czvf pythoninstall.tar.gz pythoninstall - Transfer the package files from the online computer to the offline computer.
scp pre_pythoninstall.tar.gz root@<offline_host>:/home/sifsuserscp pythoninstall.tar.gz root@<offline_host>:/home/sifsuser - On the offline computer, decompress the transferred files.
cd /home/sifsuser/tar -xzf /home/sifsuser/pre_pythoninstall.tar.gztar -xzf /home/sifsuser/pythoninstall.tar.gz - Install the required RPMs on the offline computer.
cd /home/sifsuser/pythoninstallyum localinstall *.rpmNote: If you see the messageThis system is not registered with an entitlement server. You can use subscription-manager to register.
, as the root user, setenabled=0in the /etc/yum/pluginconf.d/subscription-manager.conf, and run the command again. - Install Python on the offline computer.
cd /home/sifsuser/pythoninstall/Python-3.5.2./configuremakemake altinstall - Install the Python package installer on the offline computer.
cd /home/sifsuser/pythoninstall/usr/local/bin/python3.5 /home/sifsuser/pythoninstall/pip-9.0.1-py2.py3-none-any.whl/pip install --no-index --find-links=/home/sifsuser/pythoninstall/ pip-9.0.1-py2.py3-none-any.whl - On the offline computer, install the odbc cli database driver.
tar -xzf /home/sifsuser/pythoninstall/linuxx64_odbc_cli.tar.gz -C /usr/local/lib/python3.5/site-packages/ - On the offline computer, export the database home parameter.
export IBM_DB_HOME=/usr/local/lib/python3.5/site-packages/clidriver - On the offline computer, as the root user, create a text file that
is named pre_reqs.txtin the /home/sifsuser, and add the
following lines to the file:
h5py==2.7.0 keras==2.0.2 numpy==1.12.1 pyyaml==3.12 scipy==1.0.1 six==1.11.0 - Install the prerequisite Python libraries on the offline computer.
cd /home/sifsuser/usr/local/bin/pip3.5 install --no-deps --no-index --find-links=/home/sifsuser/pre_pythoninstall -r pre_reqs.txt - On the offline computer, create a file that is named
requirements.txt in the /home/sifsuser directory, and
include the following content in the file:
beautifulsoup4==4.5.1 email_reply_parser==0.5.9 flask_cors==3.0.3 flask_restful==0.3.6 flask==0.12.2 gnip_trend_detection==0.5 hdfs==2.1.0 ibm_db==2.0.8a nltk==3.2.4 pandas==0.18.1 pypandoc==1.4 pyspark==2.3.1 requests==2.19.1 requests-kerberos==0.12.0 scikit-learn==0.18.1 segtok==1.5.6 spacy==2.0.5 statsmodels==0.8.0 tensorflow==1.8.0 textacy==0.4.1 wrapt==1.10.11 - On the offline computer, install the other libraries by running the following
commands:
/usr/local/bin/pip3.5 install --no-index --find-links=/home/sifsuser/pythoninstall/ pypandoc/usr/local/bin/pip3.5 install --no-index --find-links=/home/sifsuser/pythoninstall/ -r requirements.txt - On the offline computer, install the pgympy Bayesian network library:
cd /home/sifsuser/pythoninstall/unzip /home/sifsuser/pythoninstall/dev.zipcd /home/sifsuser/pythoninstall/pgmpy-dev//usr/local/bin/python3.5 setup.py install - On the offline computer, install spaCy.
cd /home/sifsuser/pythoninstall/usr/local/bin/pip3.5 install --no-index --find-links=/home/sifsuser/pythoninstall/ en_core_web_sm-2.0.0.tar.gzFor more information about spaCy, see the Models & Language quick start (https://spacy.io/docs/usage/models).
- On the offline computer, create a symbolic link for this model to
en:/usr/local/bin/python3.5 -m spacy link en_core_web_sm en