Linux Ubuntu 16.04-(用于Python的Oracle模块)-如何轻松安装“cx_Oracle”模块?

Linux Ubuntu 16.04-(用于Python的Oracle模块)-如何轻松安装“cx_Oracle”模块?,linux,oracle,ubuntu,Linux,Oracle,Ubuntu,我在Docker上安装了Ubuntu 16.04,希望使用Python连接到远程Oracle DB。为此,请使用cx_oracle模块 尝试: pip install cx_oracle ->投诉libaio1和libaio dev失踪 apt-get install libaio1 libaio-dev ->再次抱怨: cx_Oracle.DatabaseError:DPI-1047:无法加载64位Oracle客户端库:libclntsh.so:无法打开共享对象文件:没有此类文件或目录 是

我在Docker上安装了Ubuntu 16.04,希望使用Python连接到远程Oracle DB。为此,请使用cx_oracle模块

尝试:

pip install cx_oracle
->投诉libaio1和libaio dev失踪

apt-get install libaio1 libaio-dev
->再次抱怨: cx_Oracle.DatabaseError:DPI-1047:无法加载64位Oracle客户端库:libclntsh.so:无法打开共享对象文件:没有此类文件或目录

是否有一个命令可以在Ubuntu 16.04上正确安装cx_Oracle,或者需要手动从源代码执行所有操作->尝试自动化所有步骤


谢谢。

还没有找到简单的方法,但我就是这么做的:

这对我来说在Ubuntu 16上很有效: 从Oracle网站下载“instantclient basic linux.x64-12.2.0.1.0.zip”和“instantclient sdk linux.x64-12.2.0.1.0.zip”,然后执行以下脚本您可以逐段执行,我作为根用户执行:

apt-get install -y python-dev build-essential libaio1
mkdir -p /opt/ora/
cd /opt/ora/

## Now put 2 ZIP files:
# ('instantclient-basic-linux.x64-12.2.0.1.0.zip' and 'instantclient-sdk-linux.x64-12.2.0.1.0.zip') 
# into /opt/ora/ and unzip them -> both will be unzipped into 1 directory: /opt/ora/instantclient_12_2 

rm -rf /etc/profile.d/oracle.sh
echo "export ORACLE_HOME=/opt/ora/instantclient_12_2"  >> /etc/profile.d/oracle.sh
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME"  >> /etc/profile.d/oracle.sh
chmod 777 /etc/profile.d/oracle.sh
source /etc/profile.d/oracle.sh
env | grep -i ora  # This will check current ENVIRONMENT settings for Oracle


rm -rf /etc/ld.so.conf.d/oracle.conf
echo "/opt/ora/instantclient_12_2" >> /etc/ld.so.conf.d/oracle.conf
ldconfig
cd $ORACLE_HOME  
ls -lrth libclntsh*   # This will show which version of 'libclntsh' you have... --> needed for following line:

ln -s libclntsh.so.12.1 libclntsh.so

pip install cx_Oracle   # Maybe not needed but I did it anyway (only pip install cx_Oracle without above steps did not work for me...)
现在python脚本已经准备好使用“cx_Oracle”