5
    cytoolz/dicttoolz.c:19:10: fatal error: Python.h: No such file or directory
     19 | #include "Python.h"
        |          ^~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for cytoolz

I'm using this:

   (venv) root@x-System-Product-Name:~# pypy3 --version
Python 3.6.9 (7.3.1+dfsg-4, Apr 22 2020, 05:15:29)
[PyPy 7.3.1 with GCC 9.3.0]

I had problems with web3 installation, was able to solve up to the point of packages lru-dict, bitarray, and cytoolz. Those are the showstoppers...

I tried those solutions from the Internet, they didn't work for me:

pip3 install wheel

sudo apt-get install python-dev 
sudo apt-get install python3-dev
sudo apt-get install libevent-dev
sudo apt-get install libblas-dev libatlas-base-dev

python -m venv --upgrade ./venv

sudo apt-get install python3-dev
sudo apt install libpython3.x-dev


dpkg --add-architecture i386
apt-get update
apt-get install libssl-dev:i386

sudo apt-get install openssl libssl-dev

pip3 install --upgrade pip

sudo apt-get install libpcap-dev libpq-dev

The error persists, in the same form, with the exact same packages.

I also tried installing from manually downloaded files, still the same 'failed building wheel' error.

Tried installing GCC, and some other random ideas were tried and failed.

TylerH
  • 20,799
  • 66
  • 75
  • 101
t_k
  • 121
  • 2
  • 8
  • Is that the full trace-back? It seems rather short. It looks like the file is looking for a c library. I had a similar problem with the `mysqldb` package, where the installer was looking for a c library (.h). No solutions by others helped, as they had different error messages. Eventually what I did was I found the source code for the c library and manually pasted it into the correct directory with the name the installer was looking for. That resolved my issue. – God-status Nov 25 '21 at 21:30
  • 1
    Looks like https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjO4p7Bu7T0AhXG-KQKHdJmBC4QFnoECAIQAQ&url=https%3A%2F%2Fsvn.python.org%2Fprojects%2Fpython%2Fbranches%2Fpep-0384%2FInclude%2FPython.h&usg=AOvVaw33IFlIXpn3RneskLZ3v4C8 might be what your looking for. – God-status Nov 25 '21 at 21:34
  • I have abbreviated the full traceback as it is painfully long, here is the full version: https://pastebin.com/DQq0uqme – t_k Nov 25 '21 at 21:58
  • I see, well try creating the file manually and putting it in the right directory, I alr gave you a link to the code. – God-status Nov 25 '21 at 22:11
  • I have pasted the Python.h file into the manually downloaded packages that gave me the error, and ran pip install on them individually and same thing occurs, should I paste Python.h elsewhere like in the root venv folder? I also tried using the pypy3 pip installer and it gave the same error. – t_k Nov 25 '21 at 22:21
  • Found a solution on a blog post, updated op, thank you for the help, pointing in the right direction... although the new error still suggests that the package needs work done on it somehow. – t_k Nov 25 '21 at 22:40
  • Thank you so much, I had bashed my head against this error for ages after updating python to 3.9 in a virtualenv. I had tried everything else recommended elsewhere such as installing the python3.9-dev tools, gcc, and so on and the link you posted had the solution: `sudo ln -sv /usr/include/python3.9/* /usr/include/` – Jacksporrow Jun 11 '22 at 01:08

3 Answers3

2

It was solved in my case by installing the appropriate python3-dev package corresponding to the python version in my virtualenv:

sudo apt install python3.10-dev

I find this cleaner than messing with python.h files.

architectonic
  • 2,871
  • 2
  • 21
  • 35
1

You need the version of Python.h and associated files for PyPy, not the one from CPython. That's usually in a package called something like pypy3-dev.

Armin Rigo
  • 12,048
  • 37
  • 48
0

Migrating OP's solution from the question to an answer:

This tutorial worked: https://blog.ducthinh.net/gcc-no-such-file-python-h/

However, still the installation needs work done on it - I'm getting this error about cytoolz package (which is I decided to not mark this solved).

ImportError: /usr/local/lib/pypy3.6/dist-packages/cytoolz/itertoolz.pypy36-pp73-x86_64-linux-gnu.so:
undefined symbol: PyExc_SystemError

TylerH
  • 20,799
  • 66
  • 75
  • 101