2

I started with web development in python(ver:3.5.3) with flask. But when I tried importing zlib getting import error

Python 3.5.3 (default, Mar 20 2017, 16:01:17) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'zlib

Tried several approaches found in stack overflow from this post as,

sudo apt-get install zlib1g-dev

but this will install in my default python version i.e. 2.7.12. And in that zlib import works without any error.

I also tried below command, which should build the dependencies

sudo apt-get build-dep python3.5.3

but getting below error

Reading package lists... Done
E: You must put some 'source' URIs in your sources.list

Any other approach that I will go with ?

napster
  • 121
  • 1
  • 4
  • Fix this "E: You must put some 'source' URIs in your sources.list" issue buy enabling source code check box in "software and updates". And executed build-dep command again. But still zlib import throwing not found – napster Sep 20 '17 at 18:47
  • Run `sudo apt update` and then `sudo apt upgrade` and now try again – George Udosen Sep 21 '17 at 00:54
  • Thanks @George, tried your approach but nothing works. Now I am going ahead by creating virtualenv. – napster Sep 23 '17 at 18:44
  • @napster it could be a problem with python import paths . – user.dz Oct 18 '19 at 17:14

1 Answers1

1

Try to install the python in such a way. It includes zlib support

./configure --with-zlib
make
sudo make altinstall