I am trying to install pymupdf package on apline image but getting below error
fitz/fitz_wrap.c:2739:10: fatal error: ft2build.h: No such file or directory
2739 | #include <ft2build.h>
| ^~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
RUN pip install PyMuPDF
---> Running in 34d246d6f01b
Collecting PyMuPDF
Downloading PyMuPDF-1.18.5.tar.gz (251 kB)
Using legacy 'setup.py install' for PyMuPDF, since package 'wheel' is not installed.
Installing collected packages: PyMuPDF
Running setup.py install for PyMuPDF: started
Running setup.py install for PyMuPDF: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uxc_zm2j/pymupdf/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uxc_zm2j/pymupdf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-nipvlcn8/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/PyMuPDF
cwd: /tmp/pip-install-uxc_zm2j/pymupdf/
Complete output (20 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/fitz
copying fitz/__init__.py -> build/lib.linux-x86_64-3.8/fitz
copying fitz/fitz.py -> build/lib.linux-x86_64-3.8/fitz
copying fitz/utils.py -> build/lib.linux-x86_64-3.8/fitz
copying fitz/__main__.py -> build/lib.linux-x86_64-3.8/fitz
running build_ext
building 'fitz._fitz' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/fitz
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -Imupdf/thirdparty/freetype/include -I/usr/include/python3.8 -c fitz/fitz_wrap.c -o build/temp.linux-x86_64-3.8/fitz/fitz_wrap.o
fitz/fitz_wrap.c:2739:10: fatal error: ft2build.h: No such file or directory
2739 | #include <ft2build.h>
| ^~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uxc_zm2j/pymupdf/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uxc_zm2j/pymupdf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-nipvlcn8/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/PyMuPDF Check the logs for full command output.
WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available.
You should consider upgrading via the '/usr/bin/python3.8 -m pip install --upgrade pip' command.
The command '/bin/sh -c pip install PyMuPDF' returned a non-zero code: 1
freetype-dev in Alpine will be installed in /usr/include/freetype2. You can link headers and directories to /usr/include
apk add mupdf-dev installed mupdf with a method structure inconsistent with that of pymupdf,So you need to compile the mupdf library from source code.
FROM python:3.8-alpine
RUN apk add gcc g++ cmake make mupdf-dev freetype-dev
ARG MUPDF=1.18.0
RUN ln -s /usr/include/freetype2/ft2build.h /usr/include/ft2build.h \
&& ln -s /usr/include/freetype2/freetype/ /usr/include/freetype \
&& wget -c -q https://www.mupdf.com/downloads/archive/mupdf-${MUPDF}-source.tar.gz \
&& tar xf mupdf-${MUPDF}-source.tar.gz \
&& cd mupdf-${MUPDF}-source \
&& make HAVE_X11=no HAVE_GLUT=no shared=yes prefix=/usr/local install \
&& cd .. \
&& rm -rf *.tar.gz mupdf-${MUPDF}-source
RUN pip install PyMuPDF==1.18.9
Try this , it works
Also, Alpine's official Mupdf library has been updated to make installation easier.(Updated at 2021-04-28)
FROM python:3.8-alpine
# Add temporary virtual environment dependencies
RUN apk --no-cache add --virtual .builddeps gcc g++
# These dependency packages cannot be removed because they continue to be used in PyMupdf
RUN apk --no-cache add mupdf-dev freetype-dev jbig2dec-dev jpeg-dev openjpeg-dev
# install PyMupdf
RUN pip install pymupdf
# Remove virtual environment dependencies
RUN apk del .builddeps
For those kind of errors there are simple steps to take:
Read the error and identify the missing file, you have done it already, you seems to be missing ft2build.h
Go the the Alpine package website and browse the Contents tab
In the field File type in the name of the file you are missing; in Branch, select your Alpine version and in Repository select main
This will point you at a sepcific package, just install it via apk in your Dockerfile and you should be good to go
In your case, this is the result of such a search on Alpine version 3.12:
So you issue can be fixed adding in the existing apk command the package freetype-dev
RUN apk add --no-cache \
freetype-dev
Try to update pip first with pip install -U pip.
Here is a deep dive into the problem https://github.com/pymupdf/PyMuPDF/issues/894
there an old pip that get source from tar.gz file rather than .whl and the build has been failed because of wrong INCLUDE dir for freetype2 which is workarounded since PyMuPDF 1.18.2 but... Pypi has outdated source tar.gz.
The problem is that there is no wheel on PyPI for the envrionment established by the docker file.
In such cases, pip tries to create PyMuPDF from sources.
Because PyMuPDF is a binding for MuPDF, this in turn is bound to fail, when there is no MuPDF installation ... like here.
The solution therefore is to
either install MuPDF before installing PyMuPDF
or use one of the OS / Python combinations for which there is a wheel.
this work for me, and only work with python:3.8.10 or greater and with Pymupdf:1.18.14:
1). Only if you don't have python installed:
apk add --update py-pip
2). Install dependencies:
apk add --no-cache \
python3-dev \
mupdf-dev \
gcc \
libc-dev \
musl-dev \
jbig2dec \
openjpeg-dev \
jpeg-dev \
harfbuzz-dev
3). Create Shortcut:
ln -s /usr/lib/libjbig2dec.so.0 /usr/lib/libjbig2dec.so
4). install PymuPdf:
pip install pymupdf
only if you want do at same time:
apk add --update py-pip \
&& apk add --no-cache \
python3-dev \
mupdf-dev \
gcc \
libc-dev \
musl-dev \
jbig2dec \
openjpeg-dev \
jpeg-dev \
harfbuzz-dev \
&& ln -s /usr/lib/libjbig2dec.so.0 /usr/lib/libjbig2dec.so \
&& pip install pymupdf
Related
I got the following error while trying to install pyaudio using pip3 in ubuntu 16.04:
Collecting pyaudio
Downloading PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v55chjee-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying src/pyaudio.py -> build/lib.linux-x86_64-3.5
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.5/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v55chjee-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-mxgvewdb/pyaudio/
This should help
$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio
Tested on Ubuntu 18.04, Python 3.7.2, pyaudio 0.2.11
Added 8th of Jan 2021:
On Ubuntu 20.04 you have to use:
$ sudo apt install portaudio19-dev python3-pyaudio
For Windows, here's what I've been going through...
There're several ways to install PortAudio
vcpkg, https://vcpkg.info/port/portaudio
winget, https://winget.run/pkg/intxcc/pyaudio
Or, manually build from source and install manually
download source, http://files.portaudio.com/download.html
build with cmake, with the matching compiler(msvc/mingw) and arch(x64/x86) to your Python
put "portaudio.h" into python-include directory, e.g. c:\Python38-32\include\
put "portaudio.lib into python-lib directory, e.g. c:\Python38-32\libs
Arrh!
the "min()" macro in pyaudio's soucefile _portaudiomodule.c is troublesome, comment it out manually
pip install pyaudio --no-clean
find _portaudiomodule.c in the temp directory and manually comment-out the "min()" macro e.g. c:\Temp\pip-install-yysb8bme\pyaudio_c92585\src\_portaudiomodule.c
pip install from that directorye.g. pip install c:\Temp\pip-install-yysb8bme\pyaudio_c92585\
Or,3rd party wheels
this answer said:
pip install pipwinpipwin install pyaudio
For MacOS (Intel/Apple Silicon):
Step 1:
brew install portaudio
Step 2:
brew --prefix portaudio
The output provided from the above command, will be required in Step 3, which will look something similar to /opt/homebrew/opt/portaudio
Step 3:
Create .pydistutils.cfg in your home directory
sudo nano ~/.pydistutils.cfg
then paste the following in the file, save and exit
[build_ext]
include_dirs=<PATH FROM STEP 2>/include/
library_dirs=<PATH FROM STEP 2>/lib/
Step 4:
pip3 install pyaudio
For Centos7/RHEL:
yum install portaudio-devel alsa-lib-devel portaudio
pip install pyaudio --user
I am trying to create a docker image from a dockerfile but I keep encountering this error.
ERROR: requests-oauthlib 1.2.0 has requirement oauthlib>=3.0.0, but you'll have oauthlib 2.1.0 which is incompatible.
And this error.
Building wheel for pycurl (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/pip-install-opawrne5/pycurl/setup.py'"'"'; __file__='"'"'/pip-install-opawrne5/pycurl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /pip-wheel-lo02mho5 --python-tag cp36
cwd: /pip-install-opawrne5/pycurl/
Complete output (20 lines):
Using curl-config (libcurl 7.58.0)
Using SSL library: OpenSSL/LibreSSL/BoringSSL
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/curl
copying python/curl/__init__.py -> build/lib.linux-x86_64-3.6/curl
running build_ext
building 'pycurl' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.3" -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.6m -c src/docstrings.c -o build/temp.linux-x86_64-3.6/src/docstrings.o
In file included from src/docstrings.c:4:0:
src/pycurl.h:164:13: fatal error: openssl/ssl.h: No such file or directory
# include <openssl/ssl.h>
^~~~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pycurl
I've tried doing pip install oauthlib to get 3.1 but it still gives me the same error. It even acknowledges I have 3.1 and proceeds to uninstall it after that error has been given.
Installing collected packages: ptyprocess, tornado, terminado, decorator, ipython-genutils, traitlets, MarkupSafe, jinja2, Send2Trash, testpath, mistune, entrypoints, jupyter-core, attrs, pyrsistent, jsonschema, nbformat, defusedxml, webencodings, bleach, pandocfilters, pygments, nbconvert, pyzmq, jupyter-client, prometheus-client, wcwidth, prompt-toolkit, pickleshare, parso, jedi, pexpect, backcall, ipython, ipykernel, notebook, ipaddress, pyYAML, chardet, certifi, urllib3, requests, oauthlib, requests-oauthlib, pyasn1, pyasn1-modules, cachetools, rsa, google-auth, websocket-client, kubernetes, escapism, SQLAlchemy, Mako, python-editor, alembic, async-generator, pamela, pycparser, cffi, cryptography, pyopenssl, certipy, jupyterhub, jupyterhub-kubespawner, pycurl, jhub-remote-user-authenticator
Found existing installation: oauthlib 3.1.0
Uninstalling oauthlib-3.1.0:
Successfully uninstalled oauthlib-3.1.0
Found existing installation: cryptography 2.1.4
Uninstalling cryptography-2.1.4:
Successfully uninstalled cryptography-2.1.4
Running setup.py install for pycurl ... error
The docker file:
FROM tf_docker/py3tensor:v1
RUN apt-get install -y openslide-tools && apt-get install -y python-openslide
RUN pip install openslide-python && pip install dicom && pip install oauthlib
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get update && \
apt-get install -y git bzip2 nodejs && \
apt-get clean && \
rm -rf /var/tmp /tmp /var/lib/apt/lists/*
RUN curl -sSL -o installer.sh https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh && \
bash /installer.sh -b -f && \
rm /installer.sh
RUN npm install -g configurable-http-proxy && \
pip install --no-cache-dir \
notebook \
jupyterhub-kubespawner==0.9.* \
git+https://github.com/jupyterhub/jupyterhub.git#dcdb8d8a89d98cda411f00ac92b99f008ffaefd6 \
git+https://github.com/occ-data/jhub_remote_user_authenticator.git#53d22afbc5f75441169974fd98580d967600d700 \
pycurl==7.43.0.3
ADD /home/ubuntu/training_output/model.ckpt-112000.data-00000-of-00001 ~/model/112000.model
ADD /home/ubuntu/training_output/model.ckpt-112000.index ~/model/112000.index
ADD /home/ubuntu/training_output/model.ckpt-112000.meta ~/model/112000.meta
ADD cull_idle_servers.py /usr/local/bin/cull_idle_servers.py
ENTRYPOINT jupyterhub
The image I am building from was build from a tensorflow image with the devel-gpu-py3 tags
According to the error, you are missing the installation of a native dependency, libssl-dev. You can install it by modifying this line:
apt-get install -y git bzip2 nodejs && \
with
apt-get install -y git bzip2 nodejs libssl-dev && \
Trying to install m2crypto in a Dockerfile:
FROM python:3.7
RUN pip install m2crypto
I'm getting the following error output (truncated):
Step 7/8 : RUN pip install m2crypto
---> Running in 1204096f1488
Collecting m2crypto
Downloading https://files.pythonhosted.org/packages/23/93/1c1a887f956ec38d691af110d38059e234fc941019e0c074a66a10846813/M2Crypto-0.34.0.tar.gz (1.1MB)
Building wheels for collected packages: m2crypto
Building wheel for m2crypto (setup.py): started
Building wheel for m2crypto (setup.py): finished with status 'error'
ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ptf_nqd5/m2crypto/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-w9seu9sh --python-tag cp37:
ERROR: running bdist_wheel
...
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -I/tmp/pip-install-ptf_nqd5/m2crypto/SWIG -c SWIG/_m2crypto_wrap.c -o build/temp.linux-x86_64-3.7/SWIG/_m2crypto_wrap.o -Wno-deprecated-declarations -DTHREADING
SWIG/_m2crypto_wrap.c: In function ‘_wrap__STACK_num_set’:
SWIG/_m2crypto_wrap.c:9506:19: error: dereferencing pointer to incomplete type ‘struct stack_st’
if (arg1) (arg1)->num = arg2;
^~
... lots more errors ...
ERROR: Command "/usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ptf_nqd5/m2crypto/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xq22_pd8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-ptf_nqd5/m2crypto/
Full output at https://pastebin.com/3bmdGvdx.
Am I doing something wrong?
Solved it on my own by following the installation instructions:
FROM python:3.7
RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y python3-dev
RUN apt-get install -y swig
RUN pip install m2crypto
libssl-dev is mentioned in the instructions but is already present. apt-get update is required, or build-essential won't be found. -y is required because python3-dev is large, and apt-get install will otherwise prompt "do you want to install? [Y/n]".
I'm sure many other variations of this will also work, using other base images. But this does work.
I couldn't install textract in google colab, error message showing as below.
some people suggest to use sudo apt-get install libasound2-dev but how to do sudo... in google colab?
=== error message ==========================================================
Failed building wheel for pocketsphinx Running setup.py clean for
pocketsphinx Failed to build pocketsphinx Installing collected
packages: pocketsphinx Running setup.py install for pocketsphinx ...
error
Complete output from command /usr/bin/python3 -u -c "import setuptools,
tokenize;file='/tmp/pip-install-03c_ysbm/pocketsphinx/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, file, 'exec'))" install
--record /tmp/pip-record-6n9ewg9i/install-record.txt --single-version-externally-managed --compile:
running install
running build_ext
building 'sphinxbase._sphinxbase' extension
swigging deps/sphinxbase/swig/sphinxbase.i to deps/sphinxbase/swig/sphinxbase_wrap.c
swig -python -modern -threads -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o deps/sphinxbase/swig/sphinxbase_wrap.c
deps/sphinxbase/swig/sphinxbase.i
unable to execute 'swig': No such file or directory
error: command 'swig' failed with exit status 1
===========================================================================
Thank you,
Ling
Nope you can't use sudo because you don't get root access for colab.
The problem is that you don't just need libasound2-dev but a whole host of packages. Check debian requirements in https://textract.readthedocs.io/en/stable/installation.html
Also in order to build sphinx (a requirement for textract) you need libpulse-dev. So here is the updated command list.
!apt-get install python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils \
pstotext tesseract-ocr \
flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig libasound2-dev libpulse-dev
!pip install git+https://github.com/deanmalmgren/textract
In google colab Bash commands run by prefixing the command with ‘!’.
Example:
!apt update
!apt-get install libasound2-dev
I am having issues installing a pip package on Windows 10 WSL running Debian Stretch.
While running sudo pip install invoice2data, with python3-pip installed I run into following errors.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for regex
Running setup.py clean for regex
Failed to build regex
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex_2/_regex.c -o build/temp.linux-x86_64-2.7/regex_2/_regex.o
regex_2/_regex.c:46:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, okenize;__file__='/tmp/pip-install-D9zG6P/regex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-0dvlsB/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-D9zG6P/regex/
WSL is unrelated to the issue, this is a fairly standard error.
Ensure the following packages are installed. Install them using apt-get install packagename. The issue this particular time was resolved by installing python-dev.
python3
python3-pip
ipython3
build-essential
python-dev
python3-dev
As a single command:
sudo apt-get install python3 python3-pip ipython3 build-essential python-dev python3-dev
Had a similar error while running pip3 install pyinquirer
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a7ojseph/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a7ojseph/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-bodowot9/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/regex Check the logs for full command output.
Installing python3-dev didn't work for me, as I already had it installed. However installing build-essential did the trick and the regex module installed successfully.
I'm running Python 3.5 on Ubuntu. How I was able to install the regex Python package is:
$ sudo apt-get install libpython3.5-dev
$ pip3 install regex --no-use-wheel
Background research details:
I determined the package name that provides the missing Python.h file by using apt-file to locate it.
# install the apt-file package in case you don't have it
$ sudo apt-get install apt-file
# populate/refresh the local apt-file package data
$ sudo apt-file update
# search for /Python.h. Since it's a C header file,
# I also grep for /include to limit the results.
$ sudo apt-file search /Python.h | grep /include
libpython2.7-dbg: /usr/include/python2.7_d/Python.h
libpython2.7-dev: /usr/include/python2.7/Python.h
libpython3.5-dbg: /usr/include/python3.5dm/Python.h
libpython3.5-dev: /usr/include/python3.5m/Python.h
pypy-dev: /usr/lib/pypy/include/Python.h
Then made an educated guess as to which package I needed. Ignore Python2, ignore debug (dbg), ignore pypy, thus leaving libpython3.5-dev.
I landed on this page when I had a similar error on Alpine so I will leave this solution here for the alternate me when he has a similar issue :)
apk add build-base --no-cache
https://wiki.alpinelinux.org/wiki/GCC
restart the bash. I had the same error, but restarting helped
If your interpreter is pypy, then install following packages: using sudo apt-get install 'packagename'
pypy3
pypy3-pip
ipypy3
build-essential
pypy-dev
pypy3-dev
Works perfectly for installing nltk and regex