[Tutor] module paths

Gonzalo Garcia-Perate gonzillaaa at gmail.com
Sun Jul 6 08:32:29 CEST 2008


That's what I thought but no. There is an install of 2.4 but not in
use. /usr/local/bin/Python points to ->
/Library/Frameworks/Python.framework/Versions/2.5/bin/python

feedparser is installed in
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages

both the interactive interpreter and the one used by textmate/terminal
report to be using Python 2.5

the output of sys.path from textmate looks like this:
['/Users/gonzillaaa/Sites/python_rss',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/simplejson-1.9.1-py2.5-macosx-10.3-i386.egg',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/python_twitter-0.5-py2.5.egg',
'/Users/gonzillaaa/Sites/python_rss',
'/Users/gonzillaaa/development/Python', '/Users/gonzillaaa/bin',
'/Library/Frameworks/Python.framework/Versions/Current/bin',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages',
'/Users/gonzillaaa/Sites',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload']


there are some duplicates but nothing missing that I can see. The
output of sys.path form the interactive interpreter looks like this:

['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/simplejson-1.9.1-py2.5-macosx-10.3-i386.egg',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/python_twitter-0.5-py2.5.egg',
'/Users/gonzillaaa/Sites/python_rss',
'/Users/gonzillaaa/development/Python', '/Users/gonzillaaa/bin',
'/Library/Frameworks/Python.framework/Versions/Current/bin',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages',
'/Users/gonzillaaa/Sites',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload']



2008/7/6 arsyed <arsyed at gmail.com>:
> I copy/pasted your script and it ran fine on my end. Is it possible that
> you've got more than one installation of python and the feedparser module is
> installed somewhere other than for the python interpreter at
> /usr/local/bin/python (since that's what your script references)? Perhaps
> trying "python parse.py" will help since your code when you invoke the
> python shell.
>
> On 7/5/08, Gonzalo Garcia-Perate <gonzillaaa at gmail.com> wrote:
>>
>> I'm looking at python after a long time. I wanted to build a quick
>> parser for some rss feeds and have started using feedparser.
>>
>> When I test my code on the python interactive shell things work fine
>> but when I try to write it into a file I get the following error:
>> AttributeError: 'module' object has no attribute 'parse'
>>
>> this is what I run on the shell:
>> import feedparser
>> >>> d = feedparser.parse("http://tedblog.typepad.com/tedblog/atom.xml")
>> >>> d
>> {'feed': {'updated': u'2008-07-04T14:11:15Z', 'updated_parsed': (2008,
>> 7, 4, 14, 11, 15, 4, 186, 0), 'links': [{'href':
>> u'http://blog.ted.com/', 'type': u'text/html', 'rel': u'alternate'},
>> {'href': u'http://feeds.feedburner.com/TEDBlog', 'type':
>> u'application/atom+xml', 'rel': u'self'}], 'title': u'TED | TEDBlog',
>> etc.....
>>
>> This is what my script (which fails looks like...):
>> #!/usr/local/bin/python
>> import feedparser
>>
>> d = feedparser.parse("http://tedblog.typepad.com/tedblog/atom.xml")
>> d['feed']['title']
>>
>> I'm trying to ring this form within textmate or form the terminal at
>> different locations as (./parse.py)
>>
>> thanks
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>
>


More information about the Tutor mailing list