我想在我的代码中尝试使用sqlalchemy,但是为了使用它,我需要先安装mysql-python。我下载了这个包,但当我尝试运行 {python setup.py install} 时,出现了一个我无法理解的错误。
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-i686-2.7/MySQLdb
running build_ext
building '_mysql' extension
i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'beta',4) -D__version__=1.2.4b4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-i686-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 'i686-linux-gnu-gcc' failed with exit status 1
在执行
sudo apt-get install python2.7-dev
命令后。Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python2.7-dev : Depends: libpython2.7-dev (= 2.7.4-2ubuntu3.2) but it is not going to be installed
Depends: libexpat1-dev but it is not installable
E: Unable to correct problems, you have held broken packages.
正在读取状态信息... 完成 软件包 python-dev 无法获得,但是有另一个软件包引用了它。 这可能意味着该软件包已丢失、已被淘汰或者 仅在另一个来源中可用。 然而,以下软件包可以替代它: pythonE: 软件包 'python-dev' 没有安装候选项。` - tlbakh
libpython2.7-dev
和libexpat1-dev
,如果可以的话,接着安装python2.7-dev
。你必须解决这些依赖关系,否则无法安装python2.7-dev
。 - David de Kleer