I encountered the same problem in college having installed Linux Mint for the main project of my final year, the third solution below worked for me.
When encountering this error please note before the error it may say you are missing a package or header file — you should find those and install them and verify if it works (e.g. ssl → libssl).
For Python 2.x use:
sudo apt-get install python-dev
For Python 2.7 use:
sudo apt-get install libffi-dev
For Python 3.x use:
sudo apt-get install python3-dev
or for a specific version of Python 3, replace x
with the minor version in
sudo apt-get install python3.x-dev
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…