简体   繁体   中英

Django Eclipse Pydev environment problem

Really silly one going on here...

I need to use this bit of code...

from sentry.client.handlers import SentryHandler
if SentryHandler not in map(lambda x: x.__class__, logger.handlers):
    logger.addHandler(SentryHandler())

I just can't get it to import in Eclipse/Pydev. I get

Unresolved import: SentryHandler Unused import: SentryHandler

If I do

from sentry.client.handlers import *

it imports without error in Eclipse but I can't access the SentryHandler class.

The code definitely exists in site-packages directory. I have other packages in the site-packages directory that work perfectly.

The code actually works. It is just an Eclipse issue.

I also have an issue with one other module: import httplib2

It works also but Eclipse gives me an error importing. I am obviously missing a bit of Eclipse / Pydev knowledge.

Any ideas how to get it working.

I had the same problem. Here's what worked for me:

Go back into the Pydev configuration: window > preferences > pydev > Interpreter - (Python/Jython/IronPython)

I'm using the Python interpreter.

Although my PYTHONPATH was setup properly to include dist-packages, I still needed to hit apply (or re-apply in my case) for it to reprocess the cache. After hitting apply, the error from importing Sentry went away.

This step is covered in the Pydev manual for the interpreter configuration page:

http://pydev.org/manual_101_interpreter.html#what-if-i-add-something-new-in-my-system-pythonpath-after-configuring-it

Eclipse does not do runtime checking. If the handlers module does not contain an explicit definition of the SentryHandler class and imports it from another module (ie as a convenience) then Pydev's Parser cannot find it. I suspect this is what is happening to you however i would have to check sentry's code to confirm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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