Newbie: import works ok if in base directory but fails in other directories
Ray Smith
ray at rays-web.com
Sun Mar 3 18:29:23 EST 2002
Hi,
I'm reading "how to think like a computer scientist" and tried one of the
examples
which uses the "pickle" import library.
This is the program:
-------------
# picking example
import pickle
f = open("pickle.dat", "w")
pickle.dump(12.3, f)
pickle.dump([1,2,3], f)
f.close()
-------------
When it is saved as and run in the directory "c:\work\python\pick1.py" it
returns the following
output:
-----------
Traceback (most recent call last):
File "pick1.py", line 2, in ?
import pickle
File "c:\dev\python22\lib\pickle.py", line 6, in ?
Classes:
AttributeError: 'module' object has no attribute 'dump'
-------------
If I save the program to my base Python directory (in my case
c:\dev\python22\) and run
it everything works ok.
What do I need to do to get it to run in other directories?
Any help is much appreciated.
Thanks,
Ray Smith
More information about the Python-list
mailing list