1、安装 python-dev

sudo apt-get install python-dev

2、安装 libmysqlclient-dev

sudo apt-get install libmysqlclient-dev

3、安装 MySQL-python

sudo pip install MySQL-python

注:

     如果安装时出现错误:

      Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-8hjzp1s7/MySQL-python/

解决方法:

1、python -m pip install --upgrade pip
    出现错误:/usr/bin/python: No module named pip

2、接着  python -m ensurepip

    出现错误:ensurepip is disabled in Debian/Ubuntu for the system python.

                     Python modules For the system python are usually handled by dpkg and apt-get.

                      apt-get install python-<module name>

3、apt-get install python-pip

    Successfully installed pip-19.2.2

4、sudo pip install MySQL-python

     Installing collected packages: MySQL-python
      Successfully installed MySQL-python-1.2.5

 

附件:安装python模块的时候,报错Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) af...

       解决: 需要创建或修改配置文件(一般都是创建),linux的文件在~/.pip/pip.conf   添加:

[global]

index-url = http://mirrors.aliyun.com/pypi/simple/

[install]

trusted-host=mirrors.aliyun.com

 


 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐