[BangPypers] ReadError: opening tar file

murugadoss murugadoss2884 at gmail.com
Mon Jun 7 03:10:04 CEST 2010


Hi,
Good Morning.

1.
This is regarding installing python in 64-bit linux pc. one of the issue,
which we were talking earlier. It was recommended to install python with
32-bit gcc compiler in 64-bit m/c.
step:
while installing python in 64-bit m/c, try using
export CC='gcc -m32'
./configure --prefix = "installing directory" ; make ; make install

2.
coming to extracting tarfile :
I am able to extract a *.tar file using tarfile.extractall( ) .The same when
i try extracting *.tar.gz,check tarfile.is_tarfile( ) returning false. On
debugging, i found in ../lib/tarfile.py + 1148 (open function) where it
checks the file type and returns the file attributes is failing. Exactly
telling " *return func(name, "r", fileobj)* " This line is failing or
returning none. This happens only in 64-bit linux m/c. It is working in
32-bit linux and windows m/c.

3.on other Method,
i open the file using tarfile.open(*.tar.gz,"r:gz"). I am getting an error
as "ImportError: No module named zlib".

>>import tarfile
>>tarfile.open("*.tar.gz","r:gz")
ImportError: No module named zlib

complete error text ill post, once i reach office.

4. currently i am using,
os.path.isfile("*.tar.gz")
os.system("tar -C [some directory] -xvf *.tar.gz")

Any input on these issues will be very helpful.
Thank u.



--
Thanks & Regards
V.Murugadoss


On Mon, Jun 7, 2010 at 4:37 AM, Sridhar Ratnakumar
<sridhar.ratna at gmail.com>wrote:

> Hi Murugadoss,
>
> Try Python 2.5.5 (the latest 2.5 release), and if this problem still
> occurs, please report a bug at bugs.python.org with full steps to
> reproduce, including the original tarfile as an attachment.
>
> C:\Python25\Lib\tarfile.py is a pure Python module; so if you are
> inclined, you may debug the problem yourself. Note that before the
> `ReadError` is raised, three open methods (taropen, gzopen, bz2open)
> are called .. and these in turn raise a fine-grained exception that
> may give a hint as to what the cause of the problem is.
>
> -srid
>
> On Fri, Jun 4, 2010 at 3:45 AM, murugadoss <murugadoss2884 at gmail.com>
> wrote:
> > Thank for the reply.
> > The tar file is not corrupted, i am using the same file in 32-bit m/c and
> > able to extract it. I have attached this output also with the mail.
> > I am getting this problem only in 64-bit m/c.
> >
> > output from 32-bit m/c:
> > tarfile.is_tarfile(tar)
> > func <bound method type.gzopen of <class 'tarfile.TarFile'>>
> > func1 <tarfile.TarFile object at 0xb7f028ac>
> > True
> >
> > For reference i have tested the same in different systems.
> > --
> > Thanks & Regards
> > V.Murugadoss
> >
> >
> > On Fri, Jun 4, 2010 at 7:35 PM, Anand Balachandran Pillai <
> > abpillai at gmail.com> wrote:
> >
> >> On Fri, Jun 4, 2010 at 11:27 AM, murugadoss <murugadoss2884 at gmail.com
> >> >wrote:
> >>
> >> > Hello,
> >> >
> >> > I am trying to extract a tar file. while doing this i check the valid
> tar
> >> > file using is_tarfile( ).
> >> > It is working fine in a 32-bit linux machine with python 2.5.4 version
> >> and
> >> > when i try it out in a 64-bit linux pc, i end up saying file is
> >> > invalid(false). This machine was using python 2.4 and now i have
> upgraded
> >> > to
> >> > 2.5.4 version and I am using python 2.5.4.
> >> >
> >> > I went through the library file, tarfile.py and found in is_tarfile(),
> is
> >> > opening the tarfile using tarfile.open.
> >> > >>>tar = /root/testtar.tar.gz
> >> > >>> import tarfile
> >> > >>> tarfile.is_tarfile(tar)
> >> > False
> >> > >>> tarfile.open(tar)
> >> > Traceback (most recent call last):
> >> >  File "<stdin>", line 1, in <module>
> >> >  File "/usr/local/lib/python2.5/tarfile.py", line 1153, in open
> >> >    raise ReadError("file could not be opened successfully")
> >> > tarfile.ReadError: file could not be opened successfully
> >> >
> >>
> >> I have a test tar file named f.tar.gz.
> >>
> >> >>> import tarfile
> >> >>> tarfile.open('f.tar.gz')
> >> <tarfile.TarFile object at 0x7f8a652fdad0>
> >> >>> tarfile.is_tarfile('f.tar.gz')
> >> True
> >>
> >> and for you,
> >>
> >> >>>tar = /root/testtar.tar.gz
> >> >>> import tarfile
> >> >>> tarfile.is_tarfile(tar)
> >> False
> >>
> >> So your "tar file" is not a real tar file. No wonder it is failing
> >> to open. Does it take rocket science to figure this out ?
> >>
> >>
> >> >
> >> > Can anyone please help me
> >> >
> >>
> >> Yes, only you can help yourself now. Spend time learning!
> >>
> >>
> >> >
> >> > --
> >> > Thanks & Regards
> >> > V.Murugadoss
> >> > _______________________________________________
> >> > BangPypers mailing list
> >> > BangPypers at python.org
> >> > http://mail.python.org/mailman/listinfo/bangpypers
> >> >
> >>
> >>
> >>
> >> --
> >> --Anand
> >> _______________________________________________
> >> BangPypers mailing list
> >> BangPypers at python.org
> >> http://mail.python.org/mailman/listinfo/bangpypers
> >>
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>


More information about the BangPypers mailing list