我的操作系统是REDHAT6.6
系统自带PYTHON2
因为我想要执行WINDOWS上的PYTHON脚本,我的脚本是用PYTHON3写的,
因此升级到了PYTHON3 但旧的PYTHON2依然保留,因为YUM命令似乎要调用PYTHON2
当时也是按网上教程安装的,运行PYTHON3也没有任何问题。
接下来要安装连接MYSQL 和DB2库需要的软件。
连接MYSQL相对来说简单些,网上各种教程,但我却从来没有安装成功过。
因为服务器不能联网,好多东西都是在自己笔记本下载上传到服务器。
就因为这样 网上一半以上的贴子几乎没有参考价值。
我知道PYTHON3连接MYSQL要安装PYMYSQL这个库,但按网上的教程安装,一直报错在某个PY文件错误之类的
心灰意冷之余发现一个冷门贴子
参才:http://www.demengqi.com/archives/205
按这个贴子弄的,连接MYSQL无问题。
接下来搞连接DB2数据库
其实挺恶心DB2数据库的,因为网上资源太少太少了。
我按照自己在WINDOWS安装的流程安装了一遍,结果最后报ERROR GCC错误。
只能再继续百度
参考资料:
https://www.cnblogs.com/qq1207501666/p/6972823.html
http://www.bubuko.com/infodetail-1841717.html
其实网上好多贴子写的都很模糊,或者经常有错误,也许笔者自己看到会知道错误在哪里
但在看贴子的我们只会按照教程一步步往下走,最后肯定是各种报错。
按照上边流程下载
ibm_db-2.0.7.tar.gz
linuxx64_odbc_cli.tar.gz
这两个文件。
传到服务器目录下,解压
drwxr-xr-x 13 1020 1023 4096 Jan 23 2015 clidriver
drwxrwxrwx 7 root root 4096 Jul 7 23:52 ibm_db-2.0.7
生成这两个目录。
进入ibm_db-2.0.7执行:python setup.py install
最后会报错:
You are downloading a package which includes the Python module for IBM DB2/Informix. The module is licensed under the Apache License 2.0. The package also includes IBM ODBC and CLI Driver from IBM, which is automatically downloaded as the python module is installed on your system/device. The license agreement to the IBM ODBC and CLI Driver is available in /usr/local/Python3/lib/python3.6/site-packages/clidriver or /usr/local/Python3/lib/python3.6/site-packages/ibm_db-2.0.7-py3.6-linux-x86_64.egg/clidriver. Check for additional dependencies, which may come with their own license agreement(s). Your use of the components of the package and dependencies constitutes your acceptance of their respective license agreements. If you do not accept the terms of any license agreement(s), then delete the relevant component(s) from your device.
此时并没有真的结束,
运行PYTHON
>>> import ibm_db
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libdb2.so.1: cannot open shared object file: No such file or directory
还需要再执行一步:
cp -r /home/user/ibm_db/clidriver /usr/local/Python3/lib/python3.6/site-packages/ibm_db-2.0.7-py3.6-linux-x86_64.egg
具体情况根据自己的安装目录以及上传目录做修改
意思是要将解压文件linuxx64_odbc_cli.tar.gz文件里的clidriver 目录拷贝到/usr/local/Python3/lib/python3.6/site-packages/ibm_db-2.0.7-py3.6-linux-x86_64.egg 这个目录下边去
再进入PYTHON
import ibm_db2
正常, 无报错,执行我的PYTHON3脚本,能够正常显示不报错。
纠结好多天的问题终于解决了。
下一步计划在服务器安装UNIXODBC通过ORALCE数据库透明网关访问DB2数据库,
可惜网上教程太少,只得自己一点点研究学习。