【问题标题】:Importing cx_Oracle in Jupyter note book gives ModuleNotFoundError在 Jupyter 笔记本中导入 cx_Oracle 会出现 ModuleNotFoundError
【发布时间】:2020-11-22 13:37:59
【问题描述】:

我正在使用 jupyter notebook,我正在尝试在 jupyter book 中进行 sql 查询 但我有一个错误

【问题讨论】:

  • cx_Oracle 大写为O。你试过import cx_Oracle吗?

标签: sql database pandas oracle cx-oracle


【解决方案1】:

需要先导入包:

pip install cx-Oracle

【讨论】:

  • 您有一个拼写错误。它是 cx_Oracle ,带下划线 ;)
  • 你是对的,这不是错字。它确实存在,但它是与真实的链接。很高兴知道。
【解决方案2】:

要在您自己的笔记本电脑上安装 cx_Oracle 最新版本 8.0.0,您需要已安装以下组件:

  • Python 3x
  • Oracle Instant Client 11g 或更高版本。参考下载即时客户端版本到这个链接

https://www.oracle.com/database/technologies/instant-client/downloads.html

在 Windows 上下载和安装适用于 Python 的 cx_Oracle 包的步骤。就我而言,我更喜欢 GitHub 中提供的版本

https://github.com/oracle/python-cx_Oracle

1.单击下载 cx_Oracle 链接从 Github 下载软件包。它会将一个 zip 文件下载到您的笔记本电脑中。

2.将 zip 文件解压缩到 Windows 上的文件夹中。例如,C:\cx_oracle。

3.现在打开命令提示符,将当前目录切换到C:\cx_oracle目录安装cx_Oracle包。

4.然后运行以下命令。

python -m pip install cx_Oracle --upgrade pip

它将在 Windows 上安装适用于 Python 的 cx_Oracle 包,您将收到如下所示的消息。

Collecting pip
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 1.3MB 2.5MB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-18.0

重要提示如果您有多个版本的 Python,请使用与 Jupyter 笔记本关联的版本。

【讨论】:

    【解决方案3】:

    简而言之,anaconda 用户
    安装包时使用小写字母source

    conda install -c conda-forge cx_oracle
    

    现在在导入包时使用 init cap as

    import cx_Oracle
    

    【讨论】:

      猜你喜欢
      • 2021-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-05
      • 2020-11-20
      • 2017-12-04
      • 1970-01-01
      • 2017-10-07
      相关资源
      最近更新 更多