zhmg23

我们是如此的不同
资深运维工程师互荐群: 102123162

Python常用模块安装

最近经常需要安装一些python环境的模块,每次安装后,没有记录,都要找,今天打算开个博,记录下,后续相关安装,陆续更新!


1、首先要安装pip,linux下安装pip,我之前记录,详细可以参考如下链接

http://zhmgz.lofter.com/post/90909_8e9aae7


2、python模块安装

2.1 安装requests模块

pip install requests

报错:ImportError: cannot import name HTTPSHandler

解决办法: 重新编译安装python

wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

 tar zxvf Python-2.7.13.tgz 

 cd Python-2.7.13

 ./configure

 make

 make install 


2.2 安装PyQuery模块

pip install PyQuery

问题:

Requirement already satisfied (use --upgrade to upgrade): pyquery in /usr/local/lib/python2.7/site-packages

Cleaning up...

解决办法: pip install --upgrade pip

升级完成后,在次安装解决



2.3 安装MySQLdb模块

 wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz  --no-check-certificate

 $ tar xfz MySQL-python-1.2.3.tar.gz

 $ cd MySQL-python-1.2.3

 $ # edit site.cfg if necessary

 $ python setup.py build

 $ sudo python setup.py install  # or su first


注:如果报错:error: command 'gcc' failed with exit status 1 

解决办法:yum install gcc python-devel mysql-devel  

 

评论