问题
I am mostly a Java developer learning Python these days.
I have PyDev in Eclipse and I've properly configured, I believe.
Why? Because I am able to run Python programs in my Eclipse.
The problem is that it does not recognize this import of cx_Oracle
(even though it runs this program successfully).
The way I understand it, this cx_Oracle module is "the Python driver"
(in Java terms so to speak) to the Oracle RDBMS.
Why is that? Is there a way I can make this warning go away?
I am using these days the Anaconda distribution on Windows 10
(but I had the same issue with the official CPython distribution
so I don't think it's related to that).
This is what I have:
C:\>python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> cx_Oracle.__file__
'C:\\Programs\\Anaconda3\\lib\\site-packages\\cx_Oracle.cp36-win_amd64.pyd'
>>>
回答1:
Humm, it seems that PyDev isn't recognizing the file C:\\Programs\\Anaconda3\\lib\\site-packages\\cx_Oracle.cp36-win_amd64.pyd
as the cx_Oracle
module (Python 3 has a new naming convention for compiled modules which PyDev isn't recognizing that well right now).
This is a bug in PyDev (I'll take a look at that). In the meanwhile, adding cx_Oracle
to the list of forced builtins
should do the trick. See: http://www.pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins for more details on how to actually set that.
来源:https://stackoverflow.com/questions/48341305/import-unresolved-not-recognized-in-pydev