无法在ubuntu 18.04上安装libpython3.6-dev,libpython3.6和mysqlclient

时间:2018-10-14 04:08:27

标签: mysql python-3.x

我尝试使用pip install mysqlclient安装mysql客户端,但最终显示为

#include "Python.h"
          ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

所以我尝试安装可以检测头文件Python.h的软件包 为此,我尝试了sudo apt-get install python3.6-dev 但这导致了

    The following packages have unmet dependencies:
 python3.6-dev : Depends: python3.6 (= 3.6.6-1~18.04) but 3.6.6-1+xenial1 is to be installed
                 Depends: libpython3.6-dev (= 3.6.6-1~18.04) but it is not going to be installed
                 Depends: libpython3.6 (= 3.6.6-1~18.04) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

如何处理这种情况以及问题出在哪里?

1 个答案:

答案 0 :(得分:0)

似乎您有依赖性问题。安装libpython3.6-dev,然后安装python3.6-dev和mysql。之后,希望您能够安装mysqlclient。

sudo apt install libpython3.6-dev
sudo apt install python3.6-dev
sudo apt instal mysql-server

然后您将能够安装mysqlclient。

**如果没有发生,最好卸载并重新安装python3.6,因为许多人都以这种方式获得了解决方案。您可以看到here

您可以使用以下命令来执行此操作,然后重复上述命令。

sudo apt purge libpython3*
sudo apt-get purge python3.6
sudo apt-get autoremove && sudo apt-get autoclean
sudo apt-get install python3.6*

希望它将解决您的问题。