[Tutor] what's wrong in my command?

Dave Angel davea at ieee.org
Thu Apr 1 11:45:52 CEST 2010

Shurui Liu (Aaron Liu) wrote:
> # geek_translator3.py
> # Pickle
> import pickle
This is where you told it to load import.py.   Normally, that just 
quietly loads the standard module included with your system.
> <snip, rest of source>
> When I run it, the system gave me the feedback below:
> Traceback (most recent call last):
>   File "geek_translator3.py", line 4, in <module>
>     import pickle
>   File "/usr/local/lib/python2.5/pickle.py", line 13, in <module>
> AttributeError: 'module' object has no attribute 'dump'
> I don't understand, I don't write anything about pickle.py, why it mentioned?
> what's wrong with "import pickle"? I read many examples online whose
> has "import pickle", they all run very well.
> Thank you!
I don't have 2.5 any more, so I can't look at the same file you 
presumably have.  And line numbers will most likely be different in 
2.6.  In particular, there are lots of module comments at the beginning 
of my version of pickle.py.  You should take a look at yours, and see 
what's in line 13.   My guess it's a reference to the dump() function 
which may be defined in the same file.  Perhaps in 2.5 it was defined 

Most common cause for something like this would be that pickle imports 
some module, and you have a module by that name in your current 
directory (or elsewhere on the sys.path).  So pickle gets an error after 
importing it, trying to use a global attribute that's not there.

Wild guess - do you have a file called marshal.py in your own code?


More information about the Tutor mailing list