0

when try to install a package from pip (numba, Minerl), i get this error:

Running setup.py install for getch ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kyiq6848/getch_81d2a001bdc842c789d2feb8e967906a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kyiq6848/getch_81d2a001bdc842c789d2feb8e967906a/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d0vb8bqu/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/shawn/.local/include/python3.10/getch
         cwd: /tmp/pip-install-kyiq6848/getch_81d2a001bdc842c789d2feb8e967906a/
    Complete output (12 lines):
    running install
    running build
    running build_ext
    building 'getch' extension
    creating build
    creating build/temp.linux-x86_64-3.10
    gcc -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I/usr/include -I/usr/include/python3.10 -c getchmodule.c -o build/temp.linux-x86_64-3.10/getchmodule.o
    getchmodule.c:1:10: fatal error: Python.h: No such file or directory
        1 | #include <Python.h>
          |          ^~~~~~~~~~
    compilation terminated.
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kyiq6848/getch_81d2a001bdc842c789d2feb8e967906a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kyiq6848/getch_81d2a001bdc842c789d2feb8e967906a/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d0vb8bqu/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/shawn/.local/include/python3.10/getch Check the logs for full command output.

However, Jupyter notebooks successfully installed (sorry for the noob qn i just started learning python a month ago)

2e0byo
  • 5,305
  • 1
  • 6
  • 26
  • https://stackoverflow.com/search?q=%5Bpip%5D+fatal+error%3A+Python.h%3A+No+such+file+or+directory – phd Jan 12 '22 at 15:21

1 Answers1

1

Try pip install --only-binary. Pip is trying to compile from source and failing because the python headers aren't installed. If a precompiled binary exists it would make life easier (quicker install, no need to sort out headers) at the expense of being very slightly less optimised for your setup (=you will almost certainly not notice).

Alternatively, install the python headers. The precise method will vary depending on your linux, but you're looking for a package called something like python3-dev.

The ability to install jupyter is unrelated, particularly if you installed with the system package manager.

2e0byo
  • 5,305
  • 1
  • 6
  • 26