rblog

Python – gzip has no attribute open

Did try the following

import gzip
f = gzip.open('myfile.gz','rb')

But then got the error

AttributeError: 'module' object has no attribute 'open'

What I really should have done was to read the whole error stack

Traceback (most recent call last):
  File "gzip.py", line 1, in module
    import gzip
  File "d:\test-py\gzip.py", line 13, in 
    fileHandler = gzip.open(pathToGzFile)
AttributeError: 'module' object has no attribute 'open'module

While testing I had named my file

gzip.py

causing Python to believe that I meant “import the script I am testing”. Renamed the file to testgzip.py and it all works fine (name can be whatever, but do not name the file the same as a module you are importing)

During this I found a nice way to pretty print (pprint) the attributes of a module/object in Python, see StackOverflow

Sandsjöbacka Trail 2018

Last weekend me and my friend Bendik did participate in the three day sprint tripple run – http://sandsjobackatrail.se/. I have published a run report here https://www.hiul.no/sandsjobacka-trail-en-kickstart-pa-lopesesongen-2018/

Blog upgraded to latest version

It has been a while since the last time I did upgrade my blog engine, so it was really needed now. I did struggle trying to find the guidelines for the manual upgrade. Actually, I did not find them, so I decided to try out the automatic upgrade for the first time. And I must say I’m impressed, the whole process took about 2 minutes, upgrading from 6.5.x to now latest stable. Actually, I did now remember that I have tried out the automatic option the last time, but then it did actually fail due to me being a bit to impatient. Things must have been improved a lot since the last time since there was no way I could interrupt things now. So – B2Evolution is still best!

Hjem