2014-02-28 4 views
4

Python 2.7을 시작하면 문제없이 import zlib을 사용할 수 있습니다. 불행히도 특정 프로젝트에 Python 2.6이 필요합니다. 내가 import zlib를 입력하면, 내가 가져 오기 오류가Python 2.6 용 'zlib'모듈 없음

apt-get install zlib1g-dev 
mkdir /tmp/shell_scripts 
cd /tmp/shell_scripts 
wget http://www.python.org/ftp/python/2.6.9/Python-2.6.9.tgz 
tar -xvzf Python-2.6.9.tgz 
rm Python-2.6.9.tgz 
cd Python-2.6.9 
./configure --with-zlib 
make 
make install 
./python setup.py install 
cd /tmp 
rm -r shell_scripts 

:

나는 내가 쓴이 스크립트를 설치했습니다. 을 설치하려면 zlib이 필요합니다. 무엇이 잘못 될 수 있는지 생각해 보셨습니까?

+2

'which python' says? –

+0

'which python'은'/ usr/local/bin/python'을 말하고 파이썬 2.6.9를 시작합니다.'which python2.6'은'/ usr/local/bin/python2.6'을 말하고 파이썬 2.6.9도 시작합니다. Python 2.6.9 (unknown, Feb 28 2014, 22:49:43)' – Xiphias

답변

4

블로그에서 해결책을 찾았습니다. 심볼 링크를 만들고 환경 변수를 설정해야했습니다. 이것은 내 작업 코드입니다.

apt-get install zlib1g-dev 
cd /lib 
sudo ln -s i386-linux-gnu/libz.so.1 libz.so 

mkdir /tmp/shell_scripts 
cd /tmp/shell_scripts 
wget http://www.python.org/ftp/python/2.6.9/Python-2.6.9.tgz 
tar -xvzf Python-2.6.9.tgz 
rm Python-2.6.9.tgz 
cd Python-2.6.9 
make distclean 
export LDFLAGS="-L/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)" 
./configure 
make 
make install 
./python setup.py install 
unset LDFLAGS 
cd /tmp 
rm -r shell_scripts 

이제 import zlib은 더 이상 오류를 발생시키지 않습니다.

+1

제 경우에'libz.so.1'은'/lib/x86_64-linux-gnu/libz.so.1에있었습니다. '(Debian 8.0 jessie). – bwind

관련 문제