0

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.

4
  • Did you install Sentry library, or added python paths in you eclipse settings? Commented Dec 3, 2010 at 19:38
  • Same thing happened for me, I ignored it, as IDE warnings should only ever be taken as guidelines. I also stopped using sentry, which helped a lot. Commented Dec 3, 2010 at 20:19
  • Thankjs for that, did you have any bad experience with Sentry or did you stop using it for other reasons? It looks good but I am building a high traffic site and won't use it if it will slow it down. I need a logging framework for central logging of multiple web servers however so it might be perfect. Commented Dec 4, 2010 at 1:56
  • I installed Sentry with pip. I haven't changed Eclipse at all other than to try adding Sentry as an external library by using add folder option. It didn't make any difference. Commented Dec 4, 2010 at 4:36

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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 (i.e. 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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.