Install Python package locally
I'm a newbie to Ubuntu, so I'm sorry if question is too dumb. How can I install Python package to already installed local version of Python?
Ubuntu 14.04, Python 2.7.10 /usr/local/bin/python2.7, package I need to install is zlib
Thanks in advance
SOLVED
- $ sudo apt-get install zlib1g-dev
- $ wget python.org/ftp/python/2.7.10/Python-2.7.10.tgz
- $ tar xfz Python-2.7.10.tgz
- $ cd Python-2.7.10/
- $ ./configure --prefix /path/to/python/ --enable-ipv6
(in my case path was /usr/local ) - $ make
- $ sudo make install
Check:
$ python2.7 -c "import zlib; print(zlib.version)"
Grand thanks to all of you guys for helping with this problem!
None of the existing answers is incorrect, but similarly don't explain why you're having the problem you are, or how to fix it. Let's clear up some things:
-
zlib
is a builtin, not a packaged thing. Virtualenvs are great things but won't help here. - If you don't have it, it wasn't built when Python was built.
- You need the zlib development libraries in order for Python to be linked to it. If the
./configure
step can't find it, it'll disable it from your build.
So that having been said, sudo apt-get build-dep python2.7
will be the sanest, quickest way to get all the build dependencies for a "typical" Python build.
But then you need to reconfigure, recompile and reinstall your version of Python. Just installing the build requirements won't retroactively link it in.
As far as I know, there is no Python package that contains zlib
because that's already included into the standard library.
Try the command below to see whether the zlib
Python package is available and which version it has:
-
for Python 2.x:
python -c "import zlib; print(zlib.__version__)"
-
for Python 3.x:
python3 -c "import zlib; print(zlib.__version__)"
On my system, it outputs 1.0
for both Python versions.