Installing Python packages (Online mode)

Use the following steps to install Python in an online mode environment.

Procedure

  1. 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 -V

    If 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.

  2. Install Python.
    1. Log in as the root user, and run the following commands:
      mkdir -p /home/sifsuser/pythoninstall
      yum -y install dos2unix
      yum -y install yum-utils
      yum -y install openssl openssl-devel
      yum -y install gcc sqlite-devel bzip2 bzip2-devel gcc-c++
    2. Download and extract Python 3.5.2.
      cd /home/sifsuser/pythoninstall
      wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
      tar -xvzf /home/sifsuser/pythoninstall/Python-3.5.2.tgz
    3. Install Python.
      cd /home/sifsuser/pythoninstall/Python-3.5.2
      ./configure
      make
      make altinstall
      /usr/local/bin/python3.5 -V

      The results should show Python 3.5.2.

  3. Install the Python package installer.
    1. Download and install the Python package installer as the root user.
      cd /home/sifsuser/pythoninstall
      wget 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.whl

      The results should show Successfully installed pip-9.0.1.

    2. Enter the following command to verify the version:
      pip3.5 --version

      The result should display a Pip version that is equal to or greater than 9.0.1. You can ignore any update messages.

  4. Install the ODBC driver.

    Download the database driver as the root user by using the following command:

    wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz -P /home/sifsuser/pythoninstall
  5. Install the Python packages that are used by IBM® Surveillance Insight for Financial Services.
    1. As the root user, create a text file that is named install.sh.
    2. Add the following text to the file.
      wget https://github.com/pgmpy/pgmpy/archive/dev.zip -O /home/sifsuser/pythoninstall/dev.zip
      wget 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 install  numpy==1.12.1
      /usr/local/bin/pip3.5 install  pandas==0.18.1
      /usr/local/bin/pip3.5 install  flask==0.12.2
      /usr/local/bin/pip3.5 install  flask_cors==3.0.3
      /usr/local/bin/pip3.5 install  flask_restful==0.3.6
      /usr/local/bin/pip3.5 install  spacy==2.0.5
      /usr/local/bin/pip3.5 install  nltk==3.2.4
      /usr/local/bin/pip3.5 install  ibm_db==2.0.8a
      /usr/local/bin/pip3.5 install  beautifulsoup4==4.5.1
      /usr/local/bin/pip3.5 install  H5py==2.7.0
      /usr/local/bin/pip3.5 install  gnip_trend_detection==0.5
      /usr/local/bin/pip3.5 install  Hdfs==2.1.0
      /usr/local/bin/pip3.5 install  Requests-kerberos==0.12.0
      /usr/local/bin/pip3.5 install  Scikit-learn==0.18.1
      /usr/local/bin/pip3.5 install  statsmodels==0.8.0
      /usr/local/bin/pip3.5 install  email_reply_parser==0.5.9
      /usr/local/bin/pip3.5 install  textacy==0.4.1
      /usr/local/bin/pip3.5 install  tensorflow==1.8
      /usr/local/bin/pip3.5 install  keras==2.0.2
      /usr/local/bin/pip3.5 install  scipy==1.0.1
      /usr/local/bin/pip3.5 install  wrapt==1.10.11
      /usr/local/bin/pip3.5 install  requests==2.19.1
      /usr/local/bin/pip3.5 install  pyspark==2.3.1
      /usr/local/bin/pip3.5 install  segtok==1.5.6
    3. Give execution permissions to the file, and then run the script as the root user:
      chmod 755 install.sh
      ./install.sh
  6. Install the pgympy Bayesian network library:
    cd /home/sifsuser/pythoninstall/
    unzip /home/sifsuser/pythoninstall/dev.zip
    cd /home/sifsuser/pythoninstall/pgmpy-dev/
    /usr/local/bin/python3.5 setup.py install
  7. 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.gz

    For more information about spaCy, see the Models & Language quick start (https://spacy.io/docs/usage/models).

  8. Create a symbolic link for this model to en:
    /usr/local/bin/python3.5 -m spacy link en_core_web_sm en