我想为我的代码尝试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.
答案 0 :(得分:6)
如果是用于python 3.6,则必须安装相应的python3-dev,即:
sudo apt-get install python3.6-dev
答案 1 :(得分:3)
答案 2 :(得分:-1)
试试这个:
sudo apt-get install zlib1g-dev