elsa wrote:
Hi all,
I'm new to both this forum and Python, and I've got a bit stuck trying
to learn how to parse HTML.... here is my problem
I'm using a textbook that uses sgmllib.py for all its examples. I'm
aware that sgmllib is not in the current release, however I want to
get it to work, as I have python 2.5, and the text book uses it.
So, the first example says to type something like (to test the
sgmllib):
python sgmllib.py "path/to/my/file.html" .... example (1)
this doesn't work for me. I think I have figured out the problem -
the error says
"/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/
Python.app/Contents/MacOS/Python: can't open file 'sgmllib.py': [Errno
2] No such file or directory"
the problem is that this path is wrong. My sgmllib.py is in:
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/sgmllib.py"
if I substitute this path for sgmllib.py in example (1), everything
works fine. However, I don't want to do all that typing everytime I
want to use sgmllib.py. So, I thought maybe the problem was with
PYTHONPATH. I executed the following command:
export PYTHONPATH=/System/Library/Frameworks/Python.framework/Versions/
2.5/li/python2.5:$PYTHONPATH
this seemed to work - no errors raised. However, when I retyped
example (1), I got the same original error.
Any assistance would be much appreciated. I'm working on max os x
leopard.
Thanks,
elsa
The path in the error message simply refers to the full path string to
your Python interpreter, and reflects %0 in your shell. So I'd assume
you've got a script called 'python' on your path, which spells out the
full path name.
That has nothing to do with your problem. Your problem, as you
correctly surmised, is that Python's search path doesn't include the
directory containing sgmllib.py
Unfortunately, I haven't used Unix for over 15 years, so I don't recall the
specifics of the shell 'export' operation. But you should be able to check the
workings by inspecting the PYTHONPATH variable after trying to change it.
There are a number of places that Python looks for a .py file. My choice, for
a standard library like this that you don't plan to modify, would be to put it
in the site-packages directory. You can see exactly where that is by doing the
following in a simple script, and examining the output.
import sys
print sys.path
--
http://mail.python.org/mailman/listinfo/python-list