[Tutor] what's wrong in my command?

Dave Angel davea at ieee.org
Thu Apr 1 20:46:08 CEST 2010


Shurui Liu (Aaron Liu) wrote:
> OK, can you tell me import.py is empty or not? If it's not an empty
> document, what's its content?
>
>   
(Please don't top-post,  Add your comments after what you're quoting, or 
at the end)

That was a typo in my message.  I should have said  pickle.py,  not 
import.py.  When you import pickle, you're tell it to find and load 
pickle.py.  That's python source code, and it will generally import 
other modules.  I was suspecting module.py.  But you should start by 
looking at line 13 of pickle.py

> On Thu, Apr 1, 2010 at 5:45 AM, Dave Angel <davea at ieee.org> wrote:
>   
>> 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 elsewhere.
>>
>> 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?
>>
>> DaveA
>>
>>
>>     
>
>
>
>   



More information about the Tutor mailing list