Python 安装requests和MySQLdb

Python 安装requests和MySQLdb 0.系统版本

0.1 查看系统版本

1 [root@localhost ~]# uname -a 2 Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

1.安装requests

1.1 软件下载

1 [root@localhost ~]# wget \ 2 https://pypi.python.org/packages/b0/e1/eab4fc3752e3d240468a8c0b284607899d2fbfb236a56b7377a329aa8d09/requests-2.18.4.tar.gz#md5=081412b2ef79bdc48229891af13f4d82

1.2 解压

1 [root@localhost ~]# tar xf requests-2.18.4.tar.gz

1.3安装requests

1 [root@localhost ~]# cd requests-2.18.4 2 [root@localhost requests-2.18.4]# python setup.py install

1.4 安装报错

1 [root@1e supervisor-3.0]# python setup.py install 2 Traceback (most recent call last): 3 File "setup.py", line 31, in <module> 4 from setuptools import setup, find_packages 5 ImportError: No module named setuptools

原因是没有找到setuptools包,再次安装这个包

下载setuptools :

1 [root@localhost requests-2.18.4]#wget \ 2 https://pypi.python.org/packages/a4/c8/9a7a47f683d54d83f648d37c3e180317f80dc126a304c45dc6663246233a/setuptools-36.5.0.zip#md5=704f500dd55f4bd0be905444f3ba892c

利用unzip进行解压

1 [root@localhost requests-2.18.4]# unzip setuptools-36.5.0.zip

如果提示没有找到unzip命令,则利用yum安装即可

1 [root@localhost requests-2.18.4]# yum install zip unzip

解压完成后即可进行安装

1 [root@localhost requests-2.18.4]# cd setuptools-36.5.0 2 [root@localhost setuptools-36.5.0]# python setup.py install

安装完成后即可进行安装requests

1 [root@localhost setuptools-36.5.0]# cd ../ 2 [root@localhost requests-2.18.4]# python setup.py install

安装完成检验,进入python交互式界面进行导入包即可

[root@localhost requests-2.18.4]# python
Python 2.7.5 (default, Nov  6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>>

2.安装requests

2.1 软件下载

1 [root@localhost ~]# wget \ 2 https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c

2.2 解压并且安装

1 [root@localhost ~]# unzip MySQL-python-1.2.5.zip 2 [root@localhost ~]# cd MySQL-python-1.2.5 3 [root@localhost MySQL-python-1.2.5]# python setup.py install

2.3 安装报错

sh: mysql_config: not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "/home/zhxia/apps/source/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/home/zhxia/apps/source/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

安装libmysqlclient-dev

1 [root@localhost MySQL-python-1.2.5]# yum install libmysqlclient-dev

安装报错,并没有发现libmysqlclient-dev

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/13336.html