Can't find user module despite setting PYTHONPATH

Paul Berkowitz berkowit at silcom.com
Fri Nov 29 15:30:53 EST 2002


On 11/29/02 11:46 AM, in article BA0D042F.27479%berkowit at silcom.com, "Paul
Berkowitz" <berkowit at silcom.com> wrote:

> It worked, and printenv PYTHONPATH  echoes the same thing back.
> 
> I quit and relaunched the Python Interactive interpreter, and now I no
> longer get a SyntaxError when I call a simple module I saved in my
> ~/Library/Scripts/Python/ directory. Instead I get: an ImportError:
> 
>>>> import module1.py
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ImportError: No module named module1.py
> 
> 
> But that's not true. It's there - I can see it. I purposely haven't prefixed
> a shebang line to the file, because I'm trying to see how it imports
> modules, not runs scripts. Do I need to? The file script is simply:
> 
> print 'Hello module world!'
> 
> What am I doing wrong?
> 

OK. I discovered I'm not supposed to include the .py extension. So I removed
it. It still doesn't work:

>>> import module1
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named module1


But it's there, in my ~/Library/Scripts/Python/  directory. There must be
something wrong with my PYTHONPATH?

setenv PYTHONPATH 
.:/usr/lib/python2.2/:/Users/berkowit/Library/Scripts/Python/:/usr/lib/pytho
n2.2/plat-darwin/ # all one line

What?

-- 
Paul Berkowitz




More information about the Python-list mailing list