[Tutor] New member question (fwd)

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sun, 28 Jul 2002 22:43:49 -0700 (PDT)


Hi Laney,

Let me forward this to the Tutor mailing list; we often try to keep
everything on Tutor just to keep everyone in the loop.  *grin*


---------- Forwarded message ----------
Date: Sun, 28 Jul 2002 22:31:30 -0400
From: Laney Mills <millsl@cofc.edu>
To: 'Danny Yoo' <dyoo@hkn.eecs.berkeley.edu>
Subject: RE: [Tutor] New member question



Ok Danny,

Here is the problem I was trying to describe:

I made the customary file with the single line

print "Hellow World!"

and saved it as follows:

c:\program files\python21\Laney\hello.py

Then when I try to "import" I get the following.  Strangely notice that it
did run.

Here is the result of file path browser  (hand typed, I couldn;t copy it)

sys.path
C:\Program Files\Python21\Tools\idle
C:\Program Files\Python21\Tools\idle  (there are both these "idle" ones
C:\Program Files\Python21\DLLs
C:\Program Files\Python21\lib
C:\Program Files\Python21\lib\polat-win
C:\Program Files\Python21\lib\lib-tk
C:\Program Files\Python21\


Notice that there is no PYTHONPATH becuase I don't know and can't figure
out how to set it.  Is it done in the autoexec.bat just like path=???

Python 2.1.2 (#31, Jan 15 2002, 17:28:11) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>> import hello.py
Hello World!
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in ?
    import hello.py
ImportError: No module named py
>>>

Thanks so much.  I have really been frustrated for months with this issue
and had almost given up.

After we get this path business straight, I'm going to ask how to launch
tkinter.  Is tkinter an alternative to idle??

Laney Mills
-----Original Message-----
From:	Danny Yoo [SMTP:dyoo@hkn.eecs.berkeley.edu]
Sent:	Sunday, July 28, 2002 3:24 PM
To:	Laney Mills
Cc:	'tutor@python.org'
Subject:	Re: [Tutor] New member question



> But if I make a small module and try to open it, the program can't find
> it.  I am suspecting this problem is an issue concerning PYTHONPATH, but
> I'm not sure.  I have read news lists and tutor information and o'reilly
> "learning python", but ALL those sources given answers using concepts
> rather more sophisticated than my actual question.  Any help would be
> greatly appreciated.

That's odd!  Hmmm... I think we might need more information on this one.
How are you trying to open the module?


If you keep all your modules in a standard place, you can add the
environmental variable 'PYTHONPATH', so that Python knows about them.
For example, on my Linux system, I keep a personal directory of modules in
a directory called '/home/dyoo/src/python'.  My PYTHONPATH will look like:

    PYTHONPATH='/home/dyoo/src/python'

and that should be it; afterwards, I can do an 'import
[name-of-my-module]' statement in other programs, and it should import the
module ok.



> Also, what is tkinter and does it come with this distribution?  I can't
> find it, but thought it came with the download from python.org.

Tkinter is a module that provides GUI building support.  You can write
programs that open windows and bring up buttons and menus.  It should be
installed alongside Python if you're using the standard distribution from
Python.org.

If you'd like to read a little more on Tkinter, Fredrik Lundh's "An
Introduction to Tkinter" may whet your appetite:

    http://www.pythonware.com/library/tkinter/introduction/


There are other GUI toolkits available for Python; although Tkinter is
standard, another popular one is called "wxPython":

    http://www.wxpython.org/

I have to admit that I haven't tried wxPython yet, but other people on
this list may be able to share their experiences with it.


If you have more questions, please feel free to ask.  We'll be happy to
help!  Off to lunch for me.  *grin* I'll talk to you later!