Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

zpifile.py error - no crc 32 attribute

285 views
Skip to first unread message

jacob m

unread,
Aug 22, 2018, 11:23:11 AM8/22/18
to
Hi guys,
I have a problem with zipfile and zlib module, and hope to get some help.

That's my error:
" import zipfile
File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in <module>
crc32 = zlib.crc32
AttributeError: module 'zlib' has no attribute 'crc32' "

I have no idea what to do with that :/ I use this version of zipfile:
https://github.com/python/cpython/blob/3.7/Lib/zipfile.py

Somebody knows how to solve it?
Regards

Peter Pearson

unread,
Aug 22, 2018, 12:35:13 PM8/22/18
to
On Wed, 22 Aug 2018 13:12:59 +0200, jacob m <kgre...@gmail.com> wrote:
[snip]
> That's my error:
> " import zipfile
> File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in <module>
> crc32 = zlib.crc32
> AttributeError: module 'zlib' has no attribute 'crc32' "
>
> I have no idea what to do with that :/ I use this version of zipfile:
> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
>
> Somebody knows how to solve it?

zipfile imports zlib and expects zlib to define something called crc32.
On your system, for some reason, the zlib that's being imported doesn't
define anything called crc32. Is there perhaps a different zlib on
your path, hiding the real zlib?

--
To email me, substitute nowhere->runbox, invalid->com.

jacob m

unread,
Aug 22, 2018, 2:05:01 PM8/22/18
to
Hi,
" Is there perhaps a different zlib on
your path, hiding the real zlib?" - I'm unsure of that.

"sudo apt-get install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
zlib1g-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
Regards


On 22 August 2018 at 13:12, jacob m <kgre...@gmail.com> wrote:

> Hi guys,
> I have a problem with zipfile and zlib module, and hope to get some help.
>
> That's my error:
> " import zipfile
> File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
> <module>
> crc32 = zlib.crc32
> AttributeError: module 'zlib' has no attribute 'crc32' "
>
> I have no idea what to do with that :/ I use this version of zipfile:
> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
>
> Somebody knows how to solve it?
> Regards
>
>

jacob m

unread,
Aug 22, 2018, 6:43:34 PM8/22/18
to
" import zlib
print(zlib.__file__)"

When I don't have the zlib uploaded to my Python3.7 library, I have the
following error:
"Traceback (most recent call last):
File "./testx.py", line 2, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'"

When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
"zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
Python library, the result is:
"# ./testx.py
None
"
In the second case I still have the AttributeError with crc32.



On 22 August 2018 at 23:09, Ashok Arora <ashok.m...@gmail.com> wrote:

> Test this in the interpreter:-
>
> import zlib
> zlib.__file__
>
> It will return the location of zlib module.
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>

Ashok Arora

unread,
Aug 22, 2018, 6:45:49 PM8/22/18
to

Thomas Jollans

unread,
Aug 22, 2018, 7:37:31 PM8/22/18
to


On 08/23/2018 12:43 AM, jacob m wrote:
> " import zlib
> print(zlib.__file__)"
>
> When I don't have the zlib uploaded to my Python3.7 library, I have the
> following error:
> "Traceback (most recent call last):
> File "./testx.py", line 2, in <module>
> import zlib
> ModuleNotFoundError: No module named 'zlib'"

zlib is part of the standard library. It should have been there when you
installed Python.

> When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
> "zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
> Python library, the result is:

Don't do that.

 * that's not a Python package. It has no business being in the Python
path.
 * don't put things into the Python path willy-nilly. Let the canonical
tools (i.e.: pip, setup.py files, etc.) take care of it.
 * DEFINITELY don't put your own stuff into the *standard* library
location. Use site-packages/ for custom packages.

Install Python again from scratch. If you can't import zlib and zipfile
in a *clean* Python install, come back and tell us how you installed
Python and what OS/distribution you're using. Then I'm sure we can help
you figure out what went wrong.

If you installed from source and you didn't have zlib headers installed
at the time, I could imagine this happening... but I have no idea if
Python would even build without zlib.

-- Thomas


> "# ./testx.py
> None
> "
> In the second case I still have the AttributeError with crc32.
>
>
>
> On 22 August 2018 at 23:09, Ashok Arora <ashok.m...@gmail.com> wrote:
>

MRAB

unread,
Aug 22, 2018, 7:57:20 PM8/22/18
to
On 2018-08-22 23:43, jacob m wrote:
> " import zlib
> print(zlib.__file__)"
>
> When I don't have the zlib uploaded to my Python3.7 library, I have the
> following error:
> "Traceback (most recent call last):
> File "./testx.py", line 2, in <module>
> import zlib
> ModuleNotFoundError: No module named 'zlib'"
>
> When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
> "zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
> Python library, the result is:
> "# ./testx.py
> None
> "
> In the second case I still have the AttributeError with crc32.
>
In the first case, without the downloaded zlip, can you import zipfile?

If yes, try:

zipfile.zlib

From what I've seen, zlib is a built-in.

jacob m

unread,
Aug 24, 2018, 8:40:21 PM8/24/18
to
Hi all,
Thanks for your help, I reinstalled my Python and now it seems to be
working :)
Before building Python3 i uncommented:
#zlib zlibmodule.c -I$(prefix)/include
in Modules/Setup.dist and then I enabled ipv6 during the configuration.
Regards
> --
> https://mail.python.org/mailman/listinfo/python-list
>
0 new messages