我花了一段时间来尝试安装cx_Oracle。
我已经尝试过Oracle库的不同版本。与32位11.1库最接近的版本
oracle-instantclient11.1-basic-11.1.0.7.0-1.i386.rpm
oracle-instantclient11.1-devel-11.1.0.7.0-1.i386.rpm
oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.i386.rpm我将环境变量设置为:usr set | grep LD_LIBRARY_PATH=/usr/lib/oracle/11.1/client/lib: oracle _HOME=/ ~# /lib/oracle/11.1/ -i /lib PATH=/usr/lib/oracle/11.1/client/lib:/home/sekingerg/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/.rvm/bin SQLPATH=/usr/lib/oracle/11.1/client/lib:
当我运行pipinstall时,它找不到包含文件:
[~]# pip install cx_Oracle
Downloading/unpacking cx-Oracle
Running setup.py egg_info for package cx-Oracle
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build-root/cx-Oracle/setup.py", line 180, in <module>
raise DistutilsSetupError("cannot locate Oracle include files")
distutils.errors.DistutilsSetupError: cannot locate Oracle include files
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build-root/cx-Oracle/setup.py", line 180, in <module>
raise DistutilsSetupError("cannot locate Oracle include files")
distutils.errors.DistutilsSetupError: cannot locate Oracle include files
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-root/cx-Oracle
Storing complete log in /root/.pip/pip.log下面是已经安装的rpm:
[~]# rpm -qa | grep -i oracle
oracle-instantclient11.1-devel-11.1.0.7.0-1.i386
oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.i386
oracle-instantclient11.1-basic-11.1.0.7.0-1.i386
[~]#我还尝试安装cx_Oracle rpm: cx_Oracle-5.1.2-11g-py33-1.x86_64.rpm,但同样不起作用。
[~]# rpm -ipv cx_Oracle-5.1.2-11g-py33-1.x86_64.rpm
Preparing packages for installation...
cx_Oracle-5.1.2-1但是在安装之后,它仍然不被识别。
[~]# python3
Python 3.3.2 (default, Nov 18 2013, 12:27:03)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
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'
>>>发布于 2013-11-22 13:52:13
我大约在一年前为在debian中安装cx_Oracle写了这个脚本:
TMP_ORACLE_HOME="/usr/lib/oracle/11.2/client64"
dpkg -i $PWD/libpython3.2_3.2.3-2_amd64.deb
dpkg -i $PWD/libaio1_0.3.107-7_amd64.deb
dpkg -i $PWD/oracle-instantclient11.2-basic_11.2.0.3.0-2_amd64.deb
echo "$TMP_ORACLE_HOME/lib" > /etc/ld.so.conf.d/oracle.conf
echo "export ORACLE_HOME=$TMP_ORACLE_HOME" > /etc/profile.d/oracle.sh
dpkg -i $PWD/cx-oracle_5.1.2-2-py32_amd64.deb
cd /usr/lib/python3.2
mv site-packages dist-packages
ln -s dist-packages site-packages
ldconfig发布于 2014-01-17 09:04:10
我也遇到过这种情况。该问题是由于安装需要"pip install“的"sudo”权限而导致的权限问题。
注意:我使用的是oracle linux 6,所以里程可能会有所不同。
下面是在构建之后发送cx_Oracle.so的目录列表,这样您就可以看到默认权限(例如,与具有全局访问权限的cx_Freeze相比):
[vagrant@oracle /]$ ll /usr/lib64/python2.6/site-packages
total 4308
drwxr-xr-x 5 root root 4096 Jan 17 09:48 cx_Freeze
drwxr-x--- 2 root root 4096 Jan 17 11:30 cx_Oracle-5.1.2-py2.6.egg-info
-rwxr-x--- 1 root root 351475 Jan 17 11:30 cx_Oracle.so我可以用下面的代码来识别这个问题,它以根用户的身份执行python,然后“导入cx_Oracle”工作:
[vagrant@oracle cx_OracleTools-8.0]$ sudo ORACLE_HOME=/usr/lib/oracle/11.2/client64 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/oracle/11.2/client64/lib python
Python 2.6.6 (r266:84292, Oct 15 2013, 07:32:41)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> 所以..。我用锤子砸在它的头上...并让我的用户拥有它(无可否认,这是错误的解决方案,可能会在以后产生影响。-我很乐意听到让我的流浪用户"pip install“的正确方法。
希望这能帮上忙,J
发布于 2013-12-04 03:09:21
我所做的任何事情都无法解决库问题。虽然Farhadix的建议很有帮助,但在执行“导入cx_Oracle”时,我无法克服这个错误:
ImportError: libpython3.3m.so.1.0: cannot open shared object file: No such file or directory我最终删除了cx_Oracle包(rpm -e cx_Oracle-5.1.2-1.x86_64),并按照here的说明从源代码构建模块。这就是我需要做的,让这个扩展在CentOS 6.4和Python3.3上工作。
https://stackoverflow.com/questions/20136912
复制相似问题