简体   繁体   English

PyCharm无法识别已安装的模块(cx_oracle)

[英]PyCharm does not recognize module (cx_oracle) installed

I'm using anaconda with Python3 我在Python3中使用anaconda

I installed cx_oracle package using pip. 我使用pip安装了cx_oracle软件包。
When I type import cx_Oracle or run the code, the python interpreter recognizes the package and runs it, but for some reason the PyChram doesn't recognize the package and doesn't suggest me autocomplete. 当我输入import cx_Oracle或运行代码时,python解释器会识别并运行该程序包,但是由于某些原因,PyChram无法识别该程序包,因此不建议我自动完成。

As you see in the screenshot, the package name is cx-Oracle instead of cx_Oracle , so I looked for cx-Oracle in the anaconda folder (and sub folders) and changed it to cx_Oracle , but without success. 从屏幕快照中可以看到,程序包名称是cx-Oracle而不是cx_Oracle ,因此我在anaconda文件夹(和子文件夹)中查找了cx-Oracle ,并将其更改为cx_Oracle ,但没有成功。

在此处输入图片说明

This could come from various sources, the main ones being listed below: 这可能来自各种来源,主要来源如下:

First source: C++ compiler 第一个来源:C ++编译器

You probably do not have the Microsoft Visual C++ compiler. 您可能没有Microsoft Visual C ++编译器。

Download Microsoft Visual C++ 2015 and install it. 下载并安装Microsoft Visual C ++ 2015。

Then restart Pycharm and check that your problem is solved. 然后重新启动Pycharm并检查是否解决了问题。

Second source: conflicts with other packages 第二个来源:与其他软件包冲突

If you use Anaconda, you probably have the SQLAlchemy package installed, which already contains instances of sql connectors (eg pyodbc.py, cx_oracle.py, ...). 如果使用Anaconda,则可能安装了SQLAlchemy软件包,该软件包已经包含sql连接器的实例(例如pyodbc.py,cx_oracle.py等)。 Uninstalling SQLAlchemy from the project interpreter listed package (for PyCharm, go to File -> Settings -> Project Interpreter) will help solving the conflicts with the filenames. 从项目解释器列出的软件包中卸载SQLAlchemy(对于PyCharm,请转到“文件”->“设置”->“项目解释器”)将有助于解决与文件名的冲突。

The following post could also help you solving your issue: Deploying cx_Oracle in Windows 以下文章也可以帮助您解决问题: 在Windows中部署cx_Oracle

Basically, the answer lists 4 different sources of the problem (including the missing C++ compiler or the need for an Oracle client to be installed). 基本上,答案列出了4个不同的问题根源(包括缺少的C ++编译器或需要安装Oracle客户端)。

Do not rename the folders! 不要重命名文件夹! It doesn't matter that the distributed package has a dash in its name -- its developers have probably taken care of it and it is installed under Python package with underscores instead. 分布式软件包的名称中的破折号无关紧要-开发人员可能已经照顾了它,并且将其安装在Python软件包下并带有下划线。

In your terminal, check the output of "pip freeze". 在您的终端中,检查“点冻结”的输出。 Is the package listed there? 包裹在那儿吗?

If not, run "which python". 如果不是,请运行“哪个python”。 If it's not the same as you have in the project interpreters dialog, that's the problem. 如果它与项目解释器对话框中的不一样,那就是问题所在。 You should activate the right virtual environment first. 您应该首先激活正确的虚拟环境。

Also, sometimes PyCharm fails to update indices. 此外,有时PyCharm无法更新索引。 A restart or resetting interpeter may help. 重新启动或重置警报器可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM