When trying to install via pip3 on Ubuntu 20.04, which doesn't bundle Python2 headers by default, the compilation of _parser.c
fails, as it's looking for Python.h
in a Python2.7 directory.
It can be worked around with apt install python2.7-dev
. Not sure where the explicit Python2 reference is coming from - I couldn't spot it at first sight in this repo.
$ pip3 install --user streaming-form-data
Collecting streaming-form-data
Using cached streaming-form-data-1.6.0.tar.gz (91 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: streaming-form-data
Building wheel for streaming-form-data (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /tmp/tmp0ldlmrgn build_wheel /tmp/tmpwhxvefb1
cwd: /tmp/pip-install-nf4hxqoq/streaming-form-data
Complete output (53 lines):
Traceback (most recent call last):
File "/tmp/pip-build-env-uyrjh8h7/overlay/lib/python3.8/site-packages/poetry/utils/env.py", line 889, in _run
output = subprocess.check_output(
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/tmp/pip-build-env-uyrjh8h7/overlay/lib/python3.8/site-packages/poetry/utils/_compat.py", line 205, in run
raise CalledProcessError(
poetry.utils._compat.CalledProcessError: Command '['/usr/bin/python', 'setup.py', 'build', '-b', 'build']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/tmp0ldlmrgn", line 280, in <module>
main()
File "/tmp/tmp0ldlmrgn", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/tmp/tmp0ldlmrgn", line 204, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/pip-build-env-uyrjh8h7/overlay/lib/python3.8/site-packages/poetry/masonry/api.py", line 62, in build_wheel
WheelBuilder.make_in(
File "/tmp/pip-build-env-uyrjh8h7/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 55, in make_in
wb.build()
File "/tmp/pip-build-env-uyrjh8h7/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 81, in build
self._build(zip_file)
File "/tmp/pip-build-env-uyrjh8h7/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 103, in _build
self._env.run(
File "/tmp/pip-build-env-uyrjh8h7/overlay/lib/python3.8/site-packages/poetry/utils/env.py", line 856, in run
return self._run(cmd, **kwargs)
File "/tmp/pip-build-env-uyrjh8h7/overlay/lib/python3.8/site-packages/poetry/utils/env.py", line 893, in _run
raise EnvCommandError(e, input=input_)
poetry.utils.env.EnvCommandError: Command ['/usr/bin/python', 'setup.py', 'build', '-b', 'build'] errored with the following return code 1, and output:
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/streaming_form_data
copying streaming_form_data/validators.py -> build/lib.linux-x86_64-2.7/streaming_form_data
copying streaming_form_data/targets.py -> build/lib.linux-x86_64-2.7/streaming_form_data
copying streaming_form_data/parser.py -> build/lib.linux-x86_64-2.7/streaming_form_data
copying streaming_form_data/__init__.py -> build/lib.linux-x86_64-2.7/streaming_form_data
copying streaming_form_data/_parser.pyx -> build/lib.linux-x86_64-2.7/streaming_form_data
copying streaming_form_data/_parser.c -> build/lib.linux-x86_64-2.7/streaming_form_data
running build_ext
building 'streaming_form_data._parser' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/streaming_form_data
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-1x6jhf/python2.7-2.7.18~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c streaming_form_data/_parser.c -o build/temp.linux-x86_64-2.7/streaming_form_data/_parser.o
streaming_form_data/_parser.c:4:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
4 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for streaming-form-data
Failed to build streaming-form-data
ERROR: Could not build wheels for streaming-form-data which use PEP 517 and cannot be installed directly