"NameError occurred" importing feedparser when debugging

May 9, 2013 at 10:41 PM

I have version 2.7 and installed both boto and feedparser. Installing like this:
easy_install -U feedparser

At the top of the file I have:
import boto
import feedparser

Boto is fine but on feedparser I get "NameError Occurred". Going into the call stack I can see this:
Locating source for 'C:\Development\Projects\PingIt Discovery Engine\PingIt Discovery Engine\build\bdist.win32\egg\feedparser.py'. (No checksum.)
The file 'C:\Development\Projects\PingIt Discovery Engine\PingIt Discovery Engine\build\bdist.win32\egg\feedparser.py' does not exist.
Looking in script documents for 'C:\Development\Projects\PingIt Discovery Engine\PingIt Discovery Engine\build\bdist.win32\egg\feedparser.py'...
Looking in the projects for 'C:\Development\Projects\PingIt Discovery Engine\PingIt Discovery Engine\build\bdist.win32\egg\feedparser.py'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\vccorlib\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: C:\Development\Projects\PingIt Discovery Engine\PingIt Discovery Engine\build\bdist.win32\egg\feedparser.py.
The debugger could not locate the source file 'C:\Development\Projects\PingIt Discovery Engine\PingIt Discovery Engine\build\bdist.win32\egg\feedparser.py'.

This only happens when I try to debug (f5) but to start without debugging (ctrl+f5) works.

Any idea how to solve this?

May 9, 2013 at 11:24 PM
Is C:\Development\Projects\PingIt Discovery Engine\PingIt Discovery Engine\build\bdist.win32\egg\ where feedparser has been installed? It seems to be an odd location for easy_install to be putting files. In any case, it seems the debugger can't find the file, and so it assumes that you want to break on unhandled exceptions (the exception is handled, but because we can't find the source file we don't know that).

The problem can probably be solved by opening Debug->Exceptions and disabling NameError completely (go into Debug->Options and Settings and enable Enable Just my Code if NameError only has one checkbox). However, since this will prevent the debugger from breaking on other NameErrors, it would be better to figure out why the debugger can't find the source file so we can fix the issue.
May 10, 2013 at 12:06 AM
Edited May 10, 2013 at 12:07 AM
Thanks for getting back on this! No, that file path is where the visual studio project is. The feedparser is in C:\Python27\Lib\site-packages\feedparser-5.1.3-py2.7.egg. Boto is also in site-packages and it is no problem with boto.

I tried to do as you said, to remove the NameError completely. There was two check-boxes and one checked. Unchecked it. Then when I debug it was not NameError anymore but ImportError. I changed back and it was again NameError. "Enable Just my Code" is enabled.
May 10, 2013 at 9:40 AM
Looking at locals when at feedparser it looks like it looking in the egg zip:
May 10, 2013 at 4:37 PM
Edited May 10, 2013 at 4:37 PM
Ah, it's still in the egg. That probably explains why we can't get at the file's source code, and may also be why we see the wrong value for __file__ (and assume the project path).

I'm not sure if something failed to install correctly, since easy_install should extract the files (though I don't know whether that's always been the default option...).

Our zip file support is very early and still has a few issues. I've created two issues based on your feedback: GetHandledExceptionRanges() cannot read files inside zips and .egg files should be treated like .zip files

To get you going immediately, deleting the .egg file and running easy_install -Z -U feedparser (note uppercase Z) should force the zip to be extracted. Once the files are actually on disk, we won't have any trouble dealing with them.

Thanks for the feedback.
May 10, 2013 at 9:45 PM
Fantastic! I tried to find they easy_install settings for this. It works now. Thanks!