前幾個步驟可參考這篇文章:http://www.cs.utexas.edu/~mitra/csSpring2011/cs327/cx_mac.html
在進行到sudo python setup.py build 以及install的時候
明明echo $ORACLE_HOME等這些環境變量都設置的,但還是報找不到ORACLE HOME的錯誤,錯誤如下:
userdeMacBook-Pro:cx_Oracle-5.1.2 mac$ sudo python setup.py build Password: Traceback (most recent call last): File "setup.py", line 132, in <module> raise DistutilsSetupError("cannot locate an Oracle software " \ distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation userdeMacBook-Pro:cx_Oracle-5.1.2 mac$ sudo echo $ORACLE_HOME /Users/mac/oracle/instantclient_11_2
根據提示找到setup.py文件的132行,寫的是
119 120 # try to determine the Oracle home 121 #userOracleHome = os.environ.get("ORACLE_HOME") 122 userOracleHome="/Users/mac/oracle/instantclient_11_2" 123 if userOracleHome is not None: 124 if not CheckOracleHome(userOracleHome): 125 messageFormat = "Oracle home (%s) does not refer to an " \ 126 "9i, 10g or 11g installation." 127 raise DistutilsSetupError(messageFormat % userOracleHome) 128 else: 129 for path in os.environ["PATH"].split(os.pathsep): 130 if CheckOracleHome(path): 131 break 132 if oracleHome is None: 133 raise DistutilsSetupError("cannot locate an Oracle software " \ 134 "installation")
找不到目錄就打出異常,程序退出,我這里在122行給他這個目錄強行寫死了(確保該目錄的確存在)
然后在執行安裝,程序順利通過。