1、安装setuptools和pip
安装完python后,需要安装pip,参考网上教程有说可以用easy_install安装pip,那就先安装easy_install再安装pip,安装easy_install和pip的方法如下:
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz tar -vxf setuptools-1.4.2.tar.gz cd setuptools-1.4.2 python2.7 setup.py install easy_install-2.7 pip ln -sv /usr/local/python27/bin/pip2.7 /usr/bin/pip27 ln -sv /usr/local/python27/bin/easy_install-2.7 /usr/bin/easy_install
参考:
http://www.jb51.net/article/57544.htm
此链接中还包括了安装mysql-python
下面的链接中包含了用easy_install安装virtualenv。命令为easy_install virtualenv暂时没有尝试
http://www.cnblogs.com/bluewhale/p/3347161.html
由于安装python时没有注意那么多,在安装easy_install和pip时报了错。
其实,以下的两个错误都是安装python之前没有安装好依赖包,如果真的如本文想用easy_install安装pip的话,那么最好先安装下列包,然后再配置重新编译安装python便可解决下面遇到的两个错误。
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline
2、安装easy_install报错如下:
[root@localhost setuptools-1.4.2]# python27 setup.py install running install running bdist_egg running egg_info writing requirements to setuptools.egg-info/requires.txt writing setuptools.egg-info/PKG-INFO writing top-level names to setuptools.egg-info/top_level.txt writing dependency_links to setuptools.egg-info/dependency_links.txt writing entry points to setuptools.egg-info/entry_points.txt reading manifest file 'setuptools.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'setuptools.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py copying setuptools.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying setuptools.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying setuptools.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying setuptools.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying setuptools.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying setuptools.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO creating 'dist/setuptools-1.4.2-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it Traceback (most recent call last): File "setup.py", line 204, indist = setuptools.setup(**setup_params) File "/usr/local/python27/lib/python2.7/distutils/core.py", line 152, in setup dist.run_commands() File "/usr/local/python27/lib/python2.7/distutils/dist.py", line 953, in run_commands self.run_command(cmd) File "/usr/local/python27/lib/python2.7/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/root/soft/setuptools-1.4.2/setuptools/command/install.py", line 73, in run self.do_egg_install() File "/root/soft/setuptools-1.4.2/setuptools/command/install.py", line 93, in do_egg_install self.run_command('bdist_egg') File "/usr/local/python27/lib/python2.7/distutils/cmd.py", line 326, in run_command self.distribution.run_command(command) File "/usr/local/python27/lib/python2.7/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/root/soft/setuptools-1.4.2/setuptools/command/bdist_egg.py", line 246, in run dry_run=self.dry_run, mode=self.gen_header()) File "/root/soft/setuptools-1.4.2/setuptools/command/bdist_egg.py", line 545, in make_zipfile z = zipfile.ZipFile(zip_filename, mode, compression=compression) File "/usr/local/python27/lib/python2.7/zipfile.py", line 732, in __init__ "Compression requires the (missing) zlib module" RuntimeError: Compression requires the (missing) zlib module
很明显,报错提示解压需要zlib模块,那就安装zlib模块:
yum install -y zlib zlib-devel
安装后还需要重新编译安装python。安装成功会在python目录下生成easy_install和easy_install-2.7脚本程序,提示如下:
Copying setuptools-1.4.2-py2.7.egg to /usr/local/python27/lib/python2.7/site-packages Adding setuptools 1.4.2 to easy-install.pth file Installing easy_install script to /usr/local/python27/bin Installing easy_install-2.7 script to /usr/local/python27/bin
参考:
http://blog.csdn.net/zhuying_linux/article/details/8167430
http://blog.csdn.net/u012538536/article/details/47360929
下面这个链接中说的是./configure时价格--with-zlib选项,不过python2.7.6中使用./configure --help并没有找到此选项,因此安装过所需的模块后,./configure时直接指定安装目录即可。
3、使用easy_install安装pip报错,报错如下:
[root@localhost setuptools-1.4.2]# /usr/local/python27/bin/easy_install-2.7 pip Searching for pip Reading https://pypi.python.org/simple/pip/ Download error on https://pypi.python.org/simple/pip/: unknown url type: https -- Some packages may not be found! Couldn't find index page for 'pip' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading https://pypi.python.org/simple/ Download error on https://pypi.python.org/simple/: unknown url type: https -- Some packages may not be found! No local packages or download links found for pip error: Could not find suitable distribution for Requirement.parse('pip')
下载错误中提示 不能识别url类型https,因为https传输是使用ssl加密传输,因此需要安装openssl-devel模块:
yum install -y openssl-devel
再次使用easy_install安装pip,安装成功后会在python目录下生成pip、pip2.7和pip2脚本程序,提示如下:
Adding pip 9.0.1 to easy-install.pth file Installing pip script to /usr/local/python27/bin Installing pip2.7 script to /usr/local/python27/bin Installing pip2 script to /usr/local/python27/bin
参考:
http://www.cnblogs.com/bluewhale/p/3347161.html
http://blog.csdn.net/u012538536/article/details/47360929