标签:python2.7安装
2、 安装python2.7
机器自带python2.4.3版本;但是,很多新功能都是基于2.7来的;比如多进程、装饰器等;
于是,需要自己准备python环境了;
python环境准备:
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz tar zxf Python-2.7.3.tgz cd Python-2.7.3 ./configure --prefix=/usr/local/python27 make make install ln -sf /usr/local/python27/bin/python2.7 /usr/local/bin/python2.7
ln -sf /usr/local/python27/bin/python2.7 /usr/local/bin/python
sudo vi .bash_profile
PATH=/usr/local/bin:$PATH
这样,python就可以直接使用了;
[admin@iZ28lzm2ehvZ Python-2.7.3]$ python --version
Python 2.7.3
[admin@iZ28lzm2ehvZ Python-2.7.3]$
然后安装setuptools,即easy_install。
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e tar zxf setuptools-0.6c11.tar.gz cd setuptools-0.6c11 python2.7 setup.py install
File "/usr/local/python27/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/admin/software/setuptools-0.6c11/setuptools/command/bdist_egg.py", line 236, in run
dry_run=self.dry_run, mode=self.gen_header())
File "/home/admin/software/setuptools-0.6c11/setuptools/command/bdist_egg.py", line 527, in make_zipfile
z = zipfile.ZipFile(zip_filename, mode, compression=compression)
File "/usr/local/python27/lib/python2.7/zipfile.py", line 681, in __init__
"Compression requires the (missing) zlib module"
RuntimeError: Compression requires the (missing) zlib module
zlib官方网站:http://www.zlib.net上下载源码来安装zlib软件包。目前最新版本zlib是zlib1.2.3,安装开始;$wget http://www.zlib.net/zlib-1.2.3.tar.gz$tar -xvzf zlib-1.2.3.tar.gz$cd zlib-1.2.3.tar.gz$./configure$make$sudo make install
安装完毕后,重新来安装一次python2.7;
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _curses _curses_panel
_ssl _tkinter
bsddb185 bz2 dbm
dl gdbm imageop
readline sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module‘s name.
ln -sf /usr/local/python27/bin/easy_install-2.7 /usr/local/bin/easy_install-2.7
ln -sf /usr/local/python27/bin/easy_install-2.7 /usr/local/bin/easy_install
easy_install
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
重新python2.7安装easy_install;重新执行,找不到包:
196 wget -c http://www.openssl.org/source/openssl-1.0.1e.tar.gz
197 tar xzvf openssl-1.0.1e.tar.gz
198 cd openssl-1.0.1e
199 ./config --prefix=/usr/local/openssl
200 make
好了,现在如果要用自带的Python,则直接运行对应的py文件即可,如果要用安装的Python2.7,则使用“python2.7 xxx.py”即可。
使用easy_install也是,自带的直接运行“easy_install xxx”,对应Python2.7的运行“easy_install2.7 xxx”。
标签:python2.7安装
原文地址:http://wenchang.blog.51cto.com/3047136/1614308