当前位置: 首页 > 知识库问答 >
问题:

无法pip安装mysql-python

孙德宇
2023-03-14

我正在尝试让django/pip/mysql工作,但我似乎不知道如何安装mySQL-Python。这是我在尝试安装mysql-python时收到的错误

pip install mysql-python

Downloading/unpacking mysql-python
  Downloading MySQL-python-1.2.4.zip (113kB): 113kB downloaded
  Running setup.py egg_info for package mysql-python
    Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
    Extracting in /tmp/tmp5jjdpf
    Now working in /tmp/tmp5jjdpf/distribute-0.6.28
    Building a Distribute egg in /home/brian/flaskapp/build/mysql-python
    /home/brian/flaskapp/build/mysql-python/distribute-0.6.28-py2.7.egg

Installing collected packages: mysql-python
  Running setup.py install for mysql-python
    building '_mysql' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
    _mysql.c:29:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /home/brian/flaskapp/bin/python -c "import setuptools;__file__='/home/brian/flaskapp/build/mysql-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ur7r16-record/install-record.txt --single-version-externally-managed --install-headers /home/brian/flaskapp/include/site/python2.7:
    running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7

creating build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb

creating build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

running build_ext

building '_mysql' extension

creating build/temp.linux-x86_64-2.7

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG

_mysql.c:29:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/brian/flaskapp/bin/python -c "import setuptools;__file__='/home/brian/flaskapp/build/mysql-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ur7r16-record/install-record.txt --single-version-externally-managed --install-headers /home/brian/flaskapp/include/site/python2.7 failed with error code 1 in /home/brian/flaskapp/build/mysql-python
Storing complete log in /home/brian/.pip/pip.log

Googling显示我需要安装python-dev,但是每当我尝试用

sudo apt-get install python-dev
E: Package 'python-dev' has no installation candidate

我目前使用的是linux mint 15 RC,我想这可能是个问题...但我不确定。我没主意了:(

共有1个答案

昝存
2023-03-14

尝试通过软件管理器下载python-dev:

sudo apt-get install python-dev
 类似资料:
  • 问题内容: 我试图让django / pip / mysql工作,但我似乎无法弄清楚如何安装mysql-python。这是我尝试安装mysql-python时收到的错误 谷歌搜索显示我需要安装python-dev但无论何时我尝试使用 我收到此错误: 我目前正在使用Linux Mint 15 RC,我认为这可能是问题所在…但我不确定。我没有主意: 问题答案: 尝试通过软件管理器下载python-de

  • 我得到一个错误 pip版本 pip-3.3-vpip1.4.1 from/usr/local/lib/python3.3/site-packages/pip-1.4.1-py3.3.egg(python 3.3) 如何安装MySQLdb在Python3.3帮助...

  • Python: 2.7.12 Pip: 8.1.1 当I时,显示如下: 例外情况: Traceback(最近的调用最后): 文件“/usr/lib/python2.7/dist packages/pip/basecommand.py”,第209行,在main中 状态=self.run(选项,参数) 文件"/usr/lib/python2.7/dist-包/pip/命令/install.py",第3

  • 错误:找不到满足httpie要求的版本(从版本:无)错误:找不到httpie的匹配分发无法获取URLhttps://pypi.org/simple/pip/:确认ssl证书时出现问题:HTTPSConnectionPool(host='pypi.org',port=443):url:/simple/pip/(由SSLError(SSLError(1,'[ssl:TLSV1_ALERT_INTERN

  • 问题内容: 我正在使用新版本的Django构建新的Django应用。我发现Django2.0可用(2.0.2)https://www.djangoproject.com/download/,现在尝试使用pip安装它。 点安装Django == 2.0.2 但这对我不起作用。 找不到满足Django == 2.0要求的版本(来自以下版本:1.1.3、1.1.4、1.2、1.2.1、1.2.2、1.2

  • 问题内容: 问题答案: 解决: 编辑settings.py