'Problems when installing python3-dev

This problem has been torturing me for 2 days, and without python3-dev I can't pip install any module, can someone tell how could I solve this?

The following packages have unmet dependencies:
     python3-dev : Depends: python3 (= 3.5.1-3) but 3.5.1-4 is to be installed
                   Depends: libpython3-dev (= 3.5.1-3) but it is not going to be installed
                   Depends: python3.5-dev (>= 3.5.1-2~) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.


Solution 1:[1]

You can try to install package libpython3-dev instead of installing package python3-dev.

I have answered a similar question here: https://superuser.com/a/1407453/1000196

Solution 2:[2]

I found a solution like this for myself on Ubuntu Desktop 20.04:

Go to "Software & Updates" application -> Then change your "Download from" server to "Main server". After this close and go terminal. Then sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove && sudo apt install python3-dev -y

Solution 3:[3]

I met this issue, and I fixed it with steps below:

  1. I tried to install libpython3-dev or python3.7-dev, it told me that "Depends: libexpat1-dev but it is not going to be installed"
  2. So I tried to install libexpat1-dev, it told me that "Depends: libexpat1 (= 2.2.6-2+deb10u4) but 2.2.6-2+deb10u1 is to be installed"
  3. Then I update libexpat1 version to 2.2.6-2+deb10u4 with command "sudo apt-get install libexpat1=2.2.6-2+deb10u4"
  4. Next, I installed libexpat1-dev, python3.7-dev, python3-dev with command below:
sudo apt-get install libexpat1-dev
sudo apt-get install python3.7-dev
sudo apt-get install python3-dev

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David17
Solution 2 Dharman
Solution 3 eraul