0

When trying to run a program that requires Python 3.5 on my Ubuntu 15.10 server, I get an error whilst importing:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/response.py", line 3, in <module>
import zlib
ImportError: No module named 'zlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "bot.py", line 12, in <module>
import discord
File "/usr/local/lib/python3.5/dist-packages/discord/__init__.py", line 21, in <module>
from .client import Client
File "/usr/local/lib/python3.5/dist-packages/discord/client.py", line 43, in <module>
import requests
File "/usr/local/lib/python3.5/dist-packages/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/local/lib/python3.5/dist-packages/requests/utils.py", line 26, in <module>
from .compat import parse_http_list as _parse_list_header
File "/usr/local/lib/python3.5/dist-packages/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/usr/local/lib/python3.5/dist-packages/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/usr/local/lib/python3.5/dist-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.5/dist-packages/urllib3/response.py", line 3, in <module>
import zlib
ImportError: No module named 'zlib'

The program itself only works with 3.5, otherwise I'd be using 3.4. Anywho, when attempting to use 3.4, there's no problems. The packages that contain zlib are installed, and they work fine with python3.4.

It might be a configuration problem, but if someone could shine some light on this, I'd really appreciate it.

EDIT

ii  libpython3.5-minimal:amd64         3.5.0-3
amd64        Minimal subset of the Python language (version 3.5)
ii  libpython3.5-stdlib:amd64          3.5.0-3                                  
amd64        Interactive high-level object-oriented language (standard library, version 3.5)
ii  python3.5                          3.5.0-3                                   
amd64        Interactive high-level object-oriented language (version 3.5)
ii  python3.5-minimal                  3.5.0-3                                  
amd64        Minimal subset of the Python language (version 3.5)

EDIT 2

ii  zlib1g:amd64                       1:1.2.8.dfsg-2ubuntu4                    amd64        compression library - runtime
ii  zlib1g-dev:amd64                   1:1.2.8.dfsg-2ubuntu4                    amd64        compression library - development
Ebear
  • 1
  • 2
  • Are the packages installed for python 3.5? – Mark Skelton Feb 29 '16 at 23:50
  • All the required packages are installed using pip for python 3.5 – Ebear Feb 29 '16 at 23:51
  • Check similar issue [no module named zlib](http://stackoverflow.com/questions/6169522/no-module-named-zlib) – Moinuddin Quadri Feb 29 '16 at 23:52
  • Checked that, pip says that all the packages brought up there are installed and ready to use. Python 3.4 recognizes them, 3.5 doesn't. – Ebear Mar 01 '16 at 00:00
  • On my Ubuntu 15.10, an `import zlib` will work and inspecting the imported module tells me ``. The package should come with support for zlib. What does `dpkg -l | grep python3.5` tell you? – jsfan Mar 01 '16 at 00:04
  • `zlib` is compiled into Python itself and not a separate package. You need to have the necessary libraries installed when *compiling* Python. – univerio Mar 01 '16 at 00:08
  • The grep has been edited into the original question. When attempting to run a file, I'm getting an error that there's no module named zlib. I'm using an API, so I don't really have an explanation for it. – Ebear Mar 01 '16 at 00:09
  • What about `dpkg -l | grep zlib`? – jsfan Mar 01 '16 at 00:14
  • All looks good. The only other thing you might want to add is `ldd /usr/bin/python3.5`. That has `libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f62f5367000)` for me. – jsfan Mar 01 '16 at 00:35
  • I changed that, still nothing. Any ideas? – Ebear Mar 01 '16 at 01:01

0 Answers0