安裝Pip
安裝epel擴展源:
yum -y install epel-release
更新完成之后申尤,就可安裝pip:
yum -y install python-pip
安裝完成之后清除cache:
yum clean all
設置鏡像源
可供選擇的源為如下:
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
華中理工大學:http://pypi.hustunique.com/
山東理工大學:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
臨時使用
在使用的時候添加參數(shù) -i 就可以了
pip install -i http://mirrors.aliyun.com/pypi/simple lxmy
永久修改
在linux系統(tǒng)下偿警, 可以修改/.pip/pip.conf(代表當前用戶的默認目錄窿凤, 如果.pip文件夾不存在, 那么就重新創(chuàng)建)
內(nèi)容如下:
[global]
index-url=http://pypi.douban.com/simple/
[install]
trusted-host=mirrors.aliyun.com
安裝MySQL-python
安裝MySQL-python必須要有mysql 客戶端押搪, 如果直接運行命令 pip install mysql-python
可能會拋出以下異常
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-RnTDKn/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-RnTDKn/mysql-python/
網(wǎng)上查了下在centos內(nèi)核版本中需要安裝mysql-devel:
yum install mysql-devel
提示安裝成功后垦细,可以接著嘗試去安裝MySQL-python模塊, 安裝過程可能會失敗压恒,報以下錯誤
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protecto r-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDE BUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_ mysql.o
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ZpgZFV/Mysql-python/setu p.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-EJsy2i-record/install-record.txt --single-version-externally-managed --compile" fai led with error code 1 in /tmp/pip-build-ZpgZFV/Mysql-python/
看報錯信息貌似是系統(tǒng)缺少相應的gcc編譯器影暴,輸入yum 安裝相應的編譯器
yum -y install gcc
再一次嘗試, 如果還是不行探赫,安裝以下包:
sudo yum install libffi-devel
sudo yum install openssl-devel
sudo yum install python-devel