I am trying to build a docker image with some libraries installed, here is my dockerfile,
FROM python:3.11.4-bookworm
WORKDIR /app
COPY ./requirements.txt ./requirements.txt
#install gcc
RUN apt-get update && apt-get install -y gcc
RUN pip install "setuptools<58.0.0"
RUN pip install python-csv
This is just a part of code that is causing issue. The error that Im getting is:
10.97 Building wheel for leven (setup.py): started
11.61 Building wheel for leven (setup.py): finished with status 'error'
11.63 error: subprocess-exited-with-error
11.63
11.63 × python setup.py bdist_wheel did not run successfully.
11.63 │ exit code: 1
11.63 ╰─> [144 lines of output]
11.63 running bdist_wheel
11.63 running build
11.63 running build_py
11.63 creating build
11.63 creating build/lib.linux-x86_64-3.11
11.63 creating build/lib.linux-x86_64-3.11/leven
11.63 copying leven/__init__.py -> build/lib.linux-x86_64-3.11/leven
11.63 running build_ext
11.63 building 'leven._levenshtein' extension
11.63 creating build/temp.linux-x86_64-3.11
11.63 creating build/temp.linux-x86_64-3.11/leven
11.63 gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ileven -I/usr/local/include/python3.11 -c leven/_levenshtein.cpp -o build/temp.linux-x86_64-3.11/leven/_levenshtein.o
11.63 In file included from /usr/local/include/python3.11/unicodeobject.h:1042,
11.63 from /usr/local/include/python3.11/Python.h:51,
11.63 from leven/_levenshtein.cpp:16:
11.63 leven/_levenshtein.cpp: In function ‘PyObject* __pyx_pf_5leven_12_levenshtein_levenshtein(PyObject*, PyObject*, PyObject*, PyObject*)’:
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:698:56: warning: ‘Py_UNICODE* PyUnicode_AS_UNICODE(PyObject*)’ is deprecated [-Wdeprecated-declarations]
11.63 698 | # define PyUnicode_AS_UNICODE(op) PyUnicode_AS_UNICODE(_PyObject_CAST(op))
11.63 | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:1004:42: note: in expansion of macro ‘PyUnicode_AS_UNICODE’
11.63 1004 | __pyx_t_7 = levenshtein_Py_UNICODE(PyUnicode_AS_UNICODE(__pyx_v_a), __pyx_v_m, PyUnicode_AS_UNICODE(__pyx_v_b), __pyx_v_n);
11.63 | ^~~~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:685:27: note: declared here
11.63 685 | static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op)
11.63 | ^~~~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:698:56: warning: ‘Py_UNICODE* PyUnicode_AS_UNICODE(PyObject*)’ is deprecated [-Wdeprecated-declarations]
11.63 698 | # define PyUnicode_AS_UNICODE(op) PyUnicode_AS_UNICODE(_PyObject_CAST(op))
11.63 | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:1004:86: note: in expansion of macro ‘PyUnicode_AS_UNICODE’
11.63 1004 | __pyx_t_7 = levenshtein_Py_UNICODE(PyUnicode_AS_UNICODE(__pyx_v_a), __pyx_v_m, PyUnicode_AS_UNICODE(__pyx_v_b), __pyx_v_n);
11.63 | ^~~~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:685:27: note: declared here
11.63 685 | static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op)
11.63 | ^~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp: In function ‘int __Pyx_InitCachedConstants()’:
11.63 leven/_levenshtein.cpp:1194:216: error: invalid conversion from ‘int’ to ‘PyObject*’ {aka ‘_object*’} [-fpermissive]11.63 1194 | __pyx_k_codeobj_4 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_5, __pyx_n_s__levenshtein, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11.63 |
^~
11.63 |
|
11.63 |
int
11.63 leven/_levenshtein.cpp:119:72: note: in definition of macro ‘__Pyx_PyCode_New’
11.63 119 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
11.63 | ^~~~~
11.63 leven/_levenshtein.cpp:1194:220: error: invalid conversion from ‘PyObject*’ {aka ‘_object*’} to ‘int’ [-fpermissive]11.63 1194 | __pyx_k_codeobj_4 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_5, __pyx_n_s__levenshtein, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11.63 |
^~~~~~~~~~~~~~~~~11.63 |
|
11.63 |
PyObject* {aka _object*}
11.63 leven/_levenshtein.cpp:119:79: note: in definition of macro ‘__Pyx_PyCode_New’
11.63 119 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
11.63 | ^~~~
11.63 leven/_levenshtein.cpp:119:21: error: too few arguments to function ‘PyCodeObject* PyCode_New(int, int, int, int, int, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, int, PyObject*, PyObject*)’
11.63 119 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
11.63 | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:1194:34: note: in expansion of macro ‘__Pyx_PyCode_New’
11.63 1194 | __pyx_k_codeobj_4 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_5, __pyx_n_s__levenshtein, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11.63 | ^~~~~~~~~~~~~~~~
11.63 In file included from /usr/local/include/python3.11/Python.h:71:
11.63 /usr/local/include/python3.11/cpython/code.h:148:28: note: declared here
11.63 148 | PyAPI_FUNC(PyCodeObject *) PyCode_New(
11.63 | ^~~~~~~~~~
11.63 leven/_levenshtein.cpp: In function ‘int __Pyx_ParseOptionalKeywords(PyObject*, PyObject***, PyObject*, PyObject**,
Py_ssize_t, const char*)’:
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:664:52: warning: ‘Py_ssize_t PyUnicode_GET_SIZE(PyObject*)’ is deprecated [-Wdeprecated-declarations]
11.63 664 | # define PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(_PyObject_CAST(op))
11.63 | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:1464:22: note: in expansion of macro ‘PyUnicode_GET_SIZE’
11.63 1464 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
11.63 | ^~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:652:26: note: declared here
11.63 652 | static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
11.63 | ^~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:664:52: warning: ‘Py_ssize_t PyUnicode_GET_SIZE(PyObject*)’ is deprecated [-Wdeprecated-declarations]
11.63 664 | # define PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(_PyObject_CAST(op))
11.63 | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:1464:52: note: in expansion of macro ‘PyUnicode_GET_SIZE’
11.63 1464 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
11.63 | ^~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:652:26: note: declared here
11.63 652 | static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
11.63 | ^~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:664:52: warning: ‘Py_ssize_t PyUnicode_GET_SIZE(PyObject*)’ is deprecated [-Wdeprecated-declarations]
11.63 664 | # define PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(_PyObject_CAST(op))
11.63 | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:1480:26: note: in expansion of macro ‘PyUnicode_GET_SIZE’
11.63 1480 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
11.63 | ^~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:652:26: note: declared here
11.63 652 | static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
11.63 | ^~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:664:52: warning: ‘Py_ssize_t PyUnicode_GET_SIZE(PyObject*)’ is deprecated [-Wdeprecated-declarations]
11.63 664 | # define PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(_PyObject_CAST(op))
11.63 | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:1480:59: note: in expansion of macro ‘PyUnicode_GET_SIZE’
11.63 1480 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
11.63 | ^~~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/unicodeobject.h:652:26: note: declared here
11.63 652 | static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
11.63 | ^~~~~~~~~~~~~~~~~~
11.63 In file included from /usr/local/include/python3.11/Python.h:95:
11.63 leven/_levenshtein.cpp: In function ‘void __Pyx_Raise(PyObject*, PyObject*, PyObject*, PyObject*)’:
11.63 /usr/local/include/python3.11/ceval.h:34:34: warning: ‘PyObject* PyEval_CallObjectWithKeywords(PyObject*, PyObject*, PyObject*)’ is deprecated [-Wdeprecated-declarations]
11.63 34 | PyEval_CallObjectWithKeywords(callable, arg, (PyObject *)NULL)
11.63 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:1644:26: note: in expansion of macro ‘PyEval_CallObject’
11.63 1644 | owned_instance = PyEval_CallObject(type, args);
11.63 | ^~~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/ceval.h:27:43: note: declared here
11.63 27 | Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
11.63 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp: In function ‘PyCodeObject* __Pyx_CreateCodeObjectForTraceback(const char*, int, int, const char*)’:
11.63 leven/_levenshtein.cpp:2483:9: error: invalid conversion from ‘int’ to ‘PyObject*’ {aka ‘_object*’} [-fpermissive]
11.63 2483 | py_line, /*int firstlineno,*/
11.63 | ^~~~~~~
11.63 | |
11.63 | int
11.63 leven/_levenshtein.cpp:119:72: note: in definition of macro ‘__Pyx_PyCode_New’
11.63 119 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
11.63 | ^~~~~
11.63 leven/_levenshtein.cpp:2484:9: error: invalid conversion from ‘PyObject*’ {aka ‘_object*’} to ‘int’ [-fpermissive]
11.63 2484 | __pyx_empty_bytes /*PyObject *lnotab*/
11.63 | ^~~~~~~~~~~~~~~~~
11.63 | |
11.63 | PyObject* {aka _object*}
11.63 leven/_levenshtein.cpp:119:79: note: in definition of macro ‘__Pyx_PyCode_New’
11.63 119 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
11.63 | ^~~~
11.63 leven/_levenshtein.cpp:119:21: error: too few arguments to function ‘PyCodeObject* PyCode_New(int, int, int, int, int, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, int, PyObject*, PyObject*)’
11.63 119 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
11.63 | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11.63 leven/_levenshtein.cpp:2469:15: note: in expansion of macro ‘__Pyx_PyCode_New’
11.63 2469 | py_code = __Pyx_PyCode_New(
11.63 | ^~~~~~~~~~~~~~~~
11.63 /usr/local/include/python3.11/cpython/code.h:148:28: note: declared here
11.63 148 | PyAPI_FUNC(PyCodeObject *) PyCode_New(
11.63 | ^~~~~~~~~~
11.63 leven/_levenshtein.cpp: In function ‘void __Pyx_AddTraceback(const char*, int, int, const char*)’:
11.63 leven/_levenshtein.cpp:2515:13: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
11.63 2515 | py_frame->f_lineno = py_line;
11.63 | ^~
11.63 In file included from /usr/local/include/python3.11/Python.h:42:
11.63 /usr/local/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}11.63 22 | typedef struct _frame PyFrameObject;
11.63 | ^~~~~~
11.63 error: command '/usr/bin/gcc' failed with exit code 1
11.63 [end of output]
11.63
11.63 note: This error originates from a subprocess, and is likely not a problem with pip.
11.63 ERROR: Failed building wheel for leven
11.63 Running setup.py clean for leven
11.75 Successfully built python-csv demjson jtutils
11.75 Failed to build leven
11.75 ERROR: Could not build wheels for leven, which is required to install pyproject.toml-based projects
11.76
11.76 [notice] A new release of pip is available: 23.1.2 -> 23.2.1
11.76 [notice] To update, run: pip install --upgrade pip
------
Dockerfile:9
--------------------
7 | # RUN apt install build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y
8 | RUN pip install "setuptools<58.0.0" cython
9 | >>> RUN pip install python-csv
10 | RUN pip install -r requirements.txt
Im guessing this is because of leven package that pip is trying to install. Using python 3.11 is a requirement. How can I fix this problem? TIA