python - cx_Oracle pip 安装失败 : oci. h: 没有那个文件或目录

标签 python pip

我对这个有 pip 迷茫。我还尝试安装旧版本的 cx_Oracle,我已将其安装在单独的 virtualenv 中,但它也在同一位置失败并显示相同的错误消息。

$ pip install cx_Oracle
(...)

cx_Oracle.c:10:17: error: oci.h: No such file or directory
cx_Oracle.c:11:18: error: orid.h: No such file or directory
cx_Oracle.c:12:16: error: xa.h: No such file or directory

error: command 'gcc' failed with exit status 1
(...)
----------------------------------------
Cleaning up...
Command /R/.virtualenv/myenv/bin/python -c "import setuptools, tokenize;__file__='/R/.virtualenv/myenv/build/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-g5eyNG-record/install-record.txt --single-version-externally-managed --compile --install-headers /R/.virtualenv/myenv/include/site/python2.7 failed with error code 1 in /R/.virtualenv/myenv/build/cx-Oracle
Traceback (most recent call last):
  File "/R/.virtualenv/myenv/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal not in range(128)

full error log

最佳答案

即使在安装 Oracle 即时客户端并设置 $ORACLE_HOME 和 $LD_LIBRARY_PATH 以包含客户端路径之后,我在尝试 pip install cx_oracle 时遇到了类似的错误。

听起来好像您可能已经安装了 Instant Client,但没有安装 Instant Client SDK。 SDK 是一个单独的下载/安装,cx_oracle 似乎需要两者,因为缺少的包含(“oci.h”和所有其他内容)位于 SDK 中。

如果您还没有去过那里,可以在这里找到 Oracle Instant Client/SDK 下载页面:

http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

假设您已经下载并安装了适合您平台的客户端,例如这个:

oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip

您还需要下载并安装相应的SDK,例如这个:

oracle-instantclient11.2-sdk-11.2.0.1.0-1.x86_64.zip

只要 SDK 安装在 ORACLE_HOME 和 LD_LIBRARY_PATH 路径中的某处,包含就应该解析。

关于python - cx_Oracle pip 安装失败 : oci. h: 没有那个文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25885467/

相关文章:

Python - 根据 2 个标准(案例和时间序列)组合 2 个数据库

python - 管理Python模块101

python - 错误 "ModuleNotFoundError: No module named ' numpy'";但已安装 NumPy

python - 强制 Python 包 setup.py bdist_wheel 在子目录中包含二进制文件

python - pip 和 pip3 - 都指向 python3.5?

python - Pandas:将包含字符串的数据帧写入多行格式的 xlsx

python - 将 OpenCV IplImage* 数据转换为 numpy 数组

python - Python 中不一致的正则表达式匹配

python - 防止对 pandas 中的列名进行排序 - python

python - 如何在 Pycharm Mac 中使用来自 Python 包交换的 Python 包?