PyCharm does not recognize module (cx_oracle) installed
Asked Answered
W

2

6

I'm using anaconda with Python3

I installed cx_oracle package using pip.
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.

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.

enter image description here

Wack answered 2/1, 2017 at 14:45 Comment(2)
Make sure that you selected the proper interpreter for your project.Sallie
It is the right interpreter.Wack
D
2

This could come from various sources, the main ones being listed below:

First source: C++ compiler

You probably do not have the Microsoft Visual C++ compiler.

Download Microsoft Visual C++ 2015 and install it.

Then restart Pycharm and check that your problem is solved.

Second source: conflicts with other packages

If you use Anaconda, you probably have the SQLAlchemy package installed, which already contains instances of sql connectors (e.g. 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.

The following post could also help you solving your issue: Deploying cx_Oracle in Windows

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).

Ductile answered 5/4, 2017 at 8:50 Comment(3)
Please remove the down vote as my answer helped me solving the exact same issue. ThanksDuctile
I was the only commenter on your post and I received that ping. I wasn't the one downvoting you, so I can't undownvote what I didn't downvote.Merchantman
Sure, my comment was just targeting the one who did it, not you!Ductile
R
0

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.

In your terminal, check the output of "pip freeze". Is the package listed there?

If not, run "which 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. A restart or resetting interpeter may help.

Rainy answered 2/1, 2017 at 15:30 Comment(2)
I typed pip freeze and the package exists, cx-Oracle==5.2.1 . I ran which python, and i the same as the project interpreters. I restarted the interpreter, in the project interpreters.Wack
It's a silly idea, but are you typing Oracle or 0racle? Zero or letter O?Rainy

© 2022 - 2024 — McMap. All rights reserved.