How To
Summary
If no proxy/internet connection machine, here is an example
how to install Python modules on a Windows machine by copying eggs.
Objective
Db2 product can be installed without internet connection but
Python modules and adapters may need to connect the internet.
If the un-networked machine can connect an internet proxy server, may work
around by using HTTP_PROXY environment variable for easy_install and
--proxy option for pip.
But if no proxy/internet connection machine, here is an example
how to install it on a Windows machine by copying eggs.
It is recommended to install the same version of Python on two boxes below.
Box [A] : internet connectable machine
Box [B] : un-networked machine, such as development box where
DB2 V11.1 M3 FP3 installed
In this example, use below Knowledge Center page and will get 8 modules/products:
* Python downloads and related resources
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.sw…
- Python
- SQLAlchemy
- Django
- ibm_db and ibm_db_dbi extensions (including source code)
- ibm_db_sa adapter for SQLAlchemy 0.4
- ibm_db_django adaptor for Django 1.0.x and 1.1
- setuptools program
- IBM Data Server Driver Package (DS Driver)
Steps
1. Download Python and setuptools on Box [A]
With referencing the URL, download below.
- python-3.7.0.exe
- setuptools-40.2.0.zip
2. Install Python on Box [A]
Right click "python-3.7.0.exe" file at Explorer ->
Select "install as administrator" ->
"Install Python 3.7.0 (32-bit)" will pop up ->
Check "Add python 3.7 to PATH" ->
Click "Install Now" (not customize installation)
* Python available for 32-bit version only.
3. Install setuptools on Box [A]
Unzip setuptools-40.2.0.zip at temp directory ->
Open a DOS prompt ->
Go to the unzipped directory ->
C:\>python setup.py install
* if python does not work, please check PATH for it.
4. Download DB2 related modules(packages) on Box [A]
Open a DOS prompt and follow below ->
C:\>mkdir \temp
C:\>cd \temp
C:\>easy_install -zmaxd . ibm_db
C:\>easy_install -zmaxd . ibm_db_sa
C:\>easy_install -zmaxd . ibm_db_django
C:\>temp directory has below files as of date 2018-09-05:
2018/09/05 16:59 <DIR> .
2018/09/05 16:59 <DIR> ..
2018/09/05 16:59 <DIR> Django-2.1.1-py3.7.egg
2018/09/05 16:45 19,587,141 ibm_db-2.0.9-py3.7.egg
2018/09/05 16:58 88,158 ibm_db_django-1.2.0.0-py3.7.egg
2018/09/05 16:56 53,019 ibm_db_sa-0.3.4-py3.7.egg
2018/09/05 16:59 <DIR> pytz-2018.5-py3.7.egg
2018/09/03 16:11 2,500,192 sqlalchemy-1.2.11-py3.7-win32.egg
* -zmaxd option should download all dependency modules
such as above Django, pytz, sqlalchemy.
* ibm_db will download below modules
- ibm_db-2.0.9-py3.7.egg
- IBM Data Server Driver Package (DS Driver) in the .egg file
* ibm_db_sa will download below modules
- ibm_db_sa-0.3.4-py3.7.egg
- sqlalchemy-1.2.11-py3.7-win32.egg
* ibm_db_django will download below modules:
- ibm_db_django-1.1.1.2.tar.gz
- Django-2.1.1-py3-none-any.whl
- pytz-2018.5-py2.py3-none-any.whl
5. Install Db2 V11.1 Mod3 FP3 on Windows 2012, Box [B]
After installed, add the license.
Open a Administrator DB2 Command window prompt and follow below ->
C:\>db2sampl
C:\>db2 connect to sample user USERID using PASSWORD
* sample database will be created and confirm to connect it
* USERID : Administrator
PASSWORD : Administrator's password
6. Install Python on Box [B] as same as step 2
7. Install setuptools on Box [B] as same as step 3
8. Copy directories and files at step 4 from Box [A] to Box [B] at C:\temp
9. Install all .egg modules on Box [B]
Open a Administrator DB2 Command window prompt and follow below ->
C:\>cd \temp
C:\>easy_install -H None -f . ibm_db
C:\>easy_install -H None -f . ibm_db_sa
C:\>easy_install -H None -f . ibm_db_django
10. Check install modules on Box [B] by pip command
C:\>pip list
Package Version
------------- -------
django 2.1.1
ibm-db 2.0.9
ibm-db-django 1.2.0.0
ibm-db-sa 0.3.4
pip 10.0.1
pytz 2018.5
setuptools 39.0.1
sqlalchemy 1.2.11
* IBM Data Server Driver Package (DS Driver) (nt32_odbc_cli.zip)
is installed and can be found at below place:
C:\User\Administrator\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\ibm_db-2.0.9-py3.7.egg\clidriver
11. Save sample1.py as below
---
# sample1.py
import ibm_db
ibm_db_conn = ibm_db.connect('database', 'user', 'password')
import ibm_db_dbi
conn = ibm_db_dbi.Connection(ibm_db_conn)
if conn:
sql = "select * from employee"
stmt = ibm_db.exec_immediate(ibm_db_conn, sql)
result = ibm_db.fetch_both(stmt)
while( result ):
print ( result[0], result[1], result[3])
result = ibm_db.fetch_both(stmt)
# end
---
* database : sample
user : Administrator
password : Administrator's password
* On none-English Windows environment, may receive an error, such as:
UnicodeDecodeError: 'ascii' codec can't decode byte xxx in position xxx
when ibm_db.conn_errormsg() is called. It may be caused by none ascii
error message is came from none-English Windows' environment installed Db2.
Db2 returns the system default encoding messages which is none-English,
such as Japanese, so raises this error message as expected behavior.
For example, it can be worked around by changing sqllib/msg/ja_JP
directory to others, such as ja_JP.bk temporary on Japanese language
default Windows system.
12. Open a Administrator DB2 Command Windows prompt and follow below ->
Then run C:\>python sample1.py
Employee number, First Name and Last Name will be returned from
employee table of sample database.
Related Information
Was this topic helpful?
Document Information
Modified date:
06 September 2018
UID
ibm10730749