gpt4 book ai didi

python - 识别 PyDev 中的 cx_Oracle 安装

转载 作者:太空狗 更新时间:2023-10-29 21:06:43 26 4
gpt4 key购买 nike

我在 Windows 10 Pro 64 位周年纪念版上使用 Python 3.5.2 (Anaconda 4.1.1)。我下载了最新的 Oracle 12c Instant Client instantclient-basic-windows.x64-12.1.0.2.0.zipinstantclient-sdk-windows.x64-12.1.0.2.0.zipC:\instantclient 并将 C:\instantclient 放在我的 PATH 上。然后我下载安装程序 cx_Oracle-5.2.1-12c.win-amd64-py3.5.exe directly from PyPI .

现在我可以启动 Anaconda python 提示符并键入 import cx_Oracle 并成功。

>>> import cx_Oracle
>>>

当我进入 Eclipse Neon (4.6) 上的 PyDev 安装时,我的源文件中的 import cx_Oracle 行仍然显示错误作为未解析的导入。

  • 我进入 Windows > Preferences > PyDev > Interpreters > Python Interpreter 并删除 Anaconda 解释器 (C:\bin\anaconda3\python.exe) 并添加它背部。我重新启动了 Eclipse,但没有成功。
  • 我对所有项目发布了Project > Clean 并重新启动了 Eclipse。它仍然将 import cx_Oracle 显示为未解析的导入。

如何让 PyDev 看到我的 cx_Oracle 包安装?

请注意,有很多假设的答案对我不起作用;如上所述,我已经尝试了所有建议。

最佳答案

您可以试试这个(在您已经在问题中报告的步骤之后)

  1. 检查 PyDev 中的安装是否正常(除了显示 import cx_Oracle 的错误标记)

    import cx_Oracle

    conn = cx_Oracle.connect('hr/hr@pdborcl')
    cur = conn.cursor()
    cur.execute('select 13 from dual')
    for r in cur.fetchall():
    print(r)

    如果这有效,并打印 (13,) 安装正确。完成的某些部分可能也可以工作。此外,在 cx_Oracle 上按住 Shift 并单击应该会报告 The definition of ... was found at ...

  2. 转到 Windows > Preferences > PyDev > Interpreters > Python Interpreter 并在选项卡上 Forced builtins 添加 cx_Oracle

    重建项目后,导入的错误标记应该会消失。 (在小测试程序中我只是做了一个简单的编辑并保存。)

备案:

Eclipse Version: 4.6.0 (Neon)
PyDev Version: 5.2.0
Python: 3.5.2 (from a virtualenv)

关于python - 识别 PyDev 中的 cx_Oracle 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39580275/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com