python安裝模組cx_Oracle
#rpm包下載地址
客戶端oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm 下載地址:
模組cx_Oracle下載地址:
#安裝前,import cx_Oracle模組報錯
[root@AWS-Dev-172-31-1-140 hadoop]# python
Python 2.7.9 (default, Apr 1 2015, 18:18:03)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cx_Oracle
#安裝rpm包,先安裝oracle客戶端,再安裝cx_Oracle模組包
[root@AWS-Dev-172-31-1-140 hadoop]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:oracle-instantclient11.2-basic-11################################# [100%]
[root@AWS-Dev-172-31-1-140 hadoop]# rpm -ivh cx_Oracle-5.1.2-11g-py27-1.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:cx_Oracle-5.1.2-1 ################################# [100%]
#設定環境變數
[root@AWS-Dev-172-31-1-140 hadoop]# cat >> /etc/profile <<!
# add by fjzcau,2016-03-24,config for oracle client which used by python
export ORACLE_HOME=/usr/lib/oracle/11.2/client64/lib
export LD_LIBRARY_PATH=\$ORACLE_HOME:\$LD_LIBRARY_PATH
export PATH=/usr/lib/oracle/11.2/client/bin:\$PATH
!
#安裝後,在python目錄下生成檔案cx_Oracle.so
[hadoop@AWS-Dev-172-31-1-140 ~]$ ll /usr/lib/python2.7/site-packages
total 360
-rw-r--r-- 1 root root 898 Jul 6 2012 cx_Oracle-5.1.2-py2.7.egg-info
-rwxr-xr-x 1 root root 360085 Jul 7 2012 cx_Oracle.so
-rw-r--r-- 1 root root 119 Apr 2 2015 README
#驗證安裝是否成功
[root@AWS-Dev-172-31-1-140 hadoop]# su - hadoop
Last login: Fri Mar 25 10:48:33 CST 2016 from submit01 on pts/2
[hadoop@AWS-Dev-172-31-1-140 ~]$ python
Python 2.7.9 (default, Apr 1 2015, 18:18:03)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>
客戶端oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm 下載地址:
模組cx_Oracle下載地址:
#安裝前,import cx_Oracle模組報錯
[root@AWS-Dev-172-31-1-140 hadoop]# python
Python 2.7.9 (default, Apr 1 2015, 18:18:03)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cx_Oracle
#安裝rpm包,先安裝oracle客戶端,再安裝cx_Oracle模組包
[root@AWS-Dev-172-31-1-140 hadoop]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:oracle-instantclient11.2-basic-11################################# [100%]
[root@AWS-Dev-172-31-1-140 hadoop]# rpm -ivh cx_Oracle-5.1.2-11g-py27-1.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:cx_Oracle-5.1.2-1 ################################# [100%]
#設定環境變數
[root@AWS-Dev-172-31-1-140 hadoop]# cat >> /etc/profile <<!
# add by fjzcau,2016-03-24,config for oracle client which used by python
export ORACLE_HOME=/usr/lib/oracle/11.2/client64/lib
export LD_LIBRARY_PATH=\$ORACLE_HOME:\$LD_LIBRARY_PATH
export PATH=/usr/lib/oracle/11.2/client/bin:\$PATH
!
#安裝後,在python目錄下生成檔案cx_Oracle.so
[hadoop@AWS-Dev-172-31-1-140 ~]$ ll /usr/lib/python2.7/site-packages
total 360
-rw-r--r-- 1 root root 898 Jul 6 2012 cx_Oracle-5.1.2-py2.7.egg-info
-rwxr-xr-x 1 root root 360085 Jul 7 2012 cx_Oracle.so
-rw-r--r-- 1 root root 119 Apr 2 2015 README
#驗證安裝是否成功
[root@AWS-Dev-172-31-1-140 hadoop]# su - hadoop
Last login: Fri Mar 25 10:48:33 CST 2016 from submit01 on pts/2
[hadoop@AWS-Dev-172-31-1-140 ~]$ python
Python 2.7.9 (default, Apr 1 2015, 18:18:03)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22661144/viewspace-2063620/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Python安裝cx_Oracle模組遇到的問題PythonOracle
- python資料庫模組-Cx_OraclePython資料庫Oracle
- python 模組安裝Python
- Python模組安裝Python
- Python安裝selenium模組Python
- python 安裝模組的方法Python
- python openssl模組如何安裝?Python
- Python安裝模組有哪些方法?Python
- Python模組、第三方模組安裝、模組匯入教程Python
- python模組安裝目錄在哪裡Python
- Python paramiko模組的安裝與使用Python
- 怎樣安裝python的GPIO模組Python
- python連線Oracle的外掛cx_Oracle安裝PythonOracle
- python(pip)包/模組:如何離線安裝?Python
- Python如何檢視安裝了哪些模組?Python
- Python 模組的製作,釋出,安裝Python
- PyMySQL模組安裝MySql
- Python:檢視已安裝模組 和 檢視可匯入模組Python
- 軟測WebUI Python安裝selenium模組失敗,用VSCode安裝成功WebUIPythonVSCode
- php 安裝zip模組PHP
- windows 安裝 Pillow 模組Windows
- Python 庫/模組的pip安裝和IPython的使用Python
- python3安裝編譯_tkinter模組丟失Python編譯
- Python怎麼安裝第三方模組Python
- Python筆記之paramiko模組安裝和使用示例Python筆記
- pip 命令安裝模組包
- pip進行模組安裝
- Python3 全自動更新已安裝的模組Python
- Python表格處理模組xlrd在Anaconda中的安裝Python
- pip高階玩法,讓python模組安裝飛起來Python
- 安裝python虛擬環境並配置虛擬環境以及安裝scrapy模組Python
- Python2、3並存,Python3無法安裝requests模組Python
- Python 安裝第三方模組的三種方法Python
- 模組的釋出和安裝
- nodejs檢查已安裝模組NodeJS
- Mac 編譯安裝 PHPRedis 模組Mac編譯PHPRedis
- 怎麼用anaconda安裝模組?
- python 模組:itsdangerous 模組Python
- Python模組:time模組Python