我正在安装python3 numba包在GitHub的动作,但安装过程显示错误:
Collecting numba==0.56.4
Downloading numba-0.56.4.tar.gz (2.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.4/2.4 MB 59.8 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [301 lines of output]
/usr/local/lib/python3.10/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
warnings.warn(
error: subprocess-exited-with-error
× Building wheel for numpy (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [258 lines of output]
Running from numpy source directory.
setup.py:86: DeprecationWarning:
`numpy.distutils` is deprecated since NumPy 1.23.0, as a result
of the deprecation of `distutils` itself. It will be removed for
Python >= 3.12. For older Python versions it will remain present.
It is recommended to use `setuptools < 60.0` for those Python versions.
For more details, see:
https://numpy.org/devdocs/reference/distutils_status_migration.html
import numpy.distutils.command.sdist
Processing numpy/random/_bounded_integers.pxd.in
Processing numpy/random/_pcg64.pyx
Processing numpy/random/_philox.pyx
Processing numpy/random/_bounded_integers.pyx.in
Processing numpy/random/_generator.pyx
Processing numpy/random/mtrand.pyx
Processing numpy/random/_common.pyx
Processing numpy/random/_mt19937.pyx
Processing numpy/random/_sfc64.pyx
Processing numpy/random/bit_generator.pyx
Cythonizing sources
INFO: blas_opt_info:
INFO: blas_armpl_info:
INFO: customize UnixCCompiler
INFO: libraries armpl_lp64_mp not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: blas_mkl_info:
INFO: libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: blis_info:
INFO: libraries blis not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: openblas_info:
INFO: libraries openblas not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: accelerate_info:
INFO: NOT AVAILABLE
INFO:
INFO: atlas_3_10_blas_threads_info:
INFO: Setting PTATLAS=ATLAS
INFO: libraries tatlas not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: atlas_3_10_blas_info:
INFO: libraries satlas not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: atlas_blas_threads_info:
INFO: Setting PTATLAS=ATLAS
INFO: libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: atlas_blas_info:
INFO: libraries f77blas,cblas,atlas not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/system_info.py:2077: UserWarning:
Optimized (vendor) Blas libraries are not found.
Falls back to netlib Blas library which has worse performance.
A better performance should be easily gained by switching
Blas library.
if self._calc_info(blas):
INFO: blas_info:
INFO: libraries blas not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/system_info.py:2077: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
if self._calc_info(blas):
INFO: blas_src_info:
INFO: NOT AVAILABLE
INFO:
/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/system_info.py:2077: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
if self._calc_info(blas):
INFO: NOT AVAILABLE
INFO:
non-existing path in 'numpy/distutils': 'site.cfg'
INFO: lapack_opt_info:
INFO: lapack_armpl_info:
INFO: libraries armpl_lp64_mp not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: lapack_mkl_info:
INFO: libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: openblas_lapack_info:
INFO: libraries openblas not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: openblas_clapack_info:
INFO: libraries openblas,lapack not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: flame_info:
INFO: libraries flame not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: atlas_3_10_threads_info:
INFO: Setting PTATLAS=ATLAS
INFO: libraries tatlas,tatlas not found in /usr/local/lib
INFO: libraries tatlas,tatlas not found in /usr/lib
INFO: <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
INFO: NOT AVAILABLE
INFO:
INFO: atlas_3_10_info:
INFO: libraries satlas,satlas not found in /usr/local/lib
INFO: libraries satlas,satlas not found in /usr/lib
INFO: <class 'numpy.distutils.system_info.atlas_3_10_info'>
INFO: NOT AVAILABLE
INFO:
INFO: atlas_threads_info:
INFO: Setting PTATLAS=ATLAS
INFO: libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
INFO: libraries ptf77blas,ptcblas,atlas not found in /usr/lib
INFO: <class 'numpy.distutils.system_info.atlas_threads_info'>
INFO: NOT AVAILABLE
INFO:
INFO: atlas_info:
INFO: libraries f77blas,cblas,atlas not found in /usr/local/lib
INFO: libraries f77blas,cblas,atlas not found in /usr/lib
INFO: <class 'numpy.distutils.system_info.atlas_info'>
INFO: NOT AVAILABLE
INFO:
INFO: lapack_info:
INFO: libraries lapack not found in ['/usr/local/lib', '/usr/lib']
INFO: NOT AVAILABLE
INFO:
/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/system_info.py:1902: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
return getattr(self, '_calc_info_{}'.format(name))()
INFO: lapack_src_info:
INFO: NOT AVAILABLE
INFO:
/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/system_info.py:1902: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
return getattr(self, '_calc_info_{}'.format(name))()
INFO: NOT AVAILABLE
INFO:
INFO: numpy_linalg_lapack_lite:
INFO: FOUND:
INFO: language = c
INFO: define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]
INFO:
Warning: attempted relative import with no known parent package
/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py:275: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
running bdist_wheel
running build
running config_cc
INFO: unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
INFO: build_src
INFO: building py_modules sources
creating build
creating build/src.linux-x86_64-3.10
creating build/src.linux-x86_64-3.10/numpy
creating build/src.linux-x86_64-3.10/numpy/distutils
INFO: building library "npymath" sources
WARN: Could not locate executable armflang
WARN: Could not locate executable gfortran
WARN: Could not locate executable f95
WARN: Could not locate executable ifort
WARN: Could not locate executable ifc
WARN: Could not locate executable lf95
WARN: Could not locate executable pgfortran
WARN: Could not locate executable nvfortran
WARN: Could not locate executable f90
WARN: Could not locate executable f77
WARN: Could not locate executable fort
WARN: Could not locate executable efort
WARN: Could not locate executable efc
WARN: Could not locate executable g77
WARN: Could not locate executable g95
WARN: Could not locate executable pathf95
WARN: Could not locate executable nagfor
WARN: Could not locate executable frt
WARN: don't know how to compile Fortran code on platform 'posix'
[Errno 2] No such file or directory: 'gcc'
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 230, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 215, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 267, in run_setup
super(_BuildMetaLegacyBackend,
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 158, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 494, in <module>
setup_package()
File "setup.py", line 486, in setup_package
setup(**metadata)
File "/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 148, in setup
dist.run_commands()
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
self.run_command(cmd)
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/command/build.py", line 62, in run
old_build.run(self)
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-t_16bsry/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/command/build_src.py", line 144, in run
self.build_sources()
File "/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/command/build_src.py", line 155, in build_sources
self.build_library_sources(*libname_info)
File "/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/command/build_src.py", line 288, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
File "/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/distutils/command/build_src.py", line 378, in generate_sources
source = func(extension, build_dir)
File "/tmp/pip-wheel-eqyou62a/numpy_571e716b8f694316af15802515ca0b00/numpy/core/setup.py", line 758, in get_mathlib_info
raise RuntimeError(
RuntimeError: Broken toolchain: cannot link a simple C program.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for numpy
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/setuptools/installer.py", line 82, in fetch_build_egg
subprocess.check_call(cmd)
File "/usr/local/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp2nz6gige', '--quiet', 'numpy<1.24,>=1.11']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-xchug7bl/numba_00413dce325d4a8a88447ef4c07c125f/setup.py", line 431, in <module>
setup(**metadata)
File "/usr/local/lib/python3.10/site-packages/setuptools/__init__.py", line 86, in setup
_install_setup_requires(attrs)
File "/usr/local/lib/python3.10/site-packages/setuptools/__init__.py", line 80, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/usr/local/lib/python3.10/site-packages/setuptools/dist.py", line 875, in fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 789, in resolve
dist = best[req.key] = env.best_match(
File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1075, in best_match
return self.obtain(req, installer)
File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1087, in obtain
return installer(requirement)
File "/usr/local/lib/python3.10/site-packages/setuptools/dist.py", line 945, in fetch_build_egg
return fetch_build_egg(self, req)
File "/usr/local/lib/python3.10/site-packages/setuptools/installer.py", line 84, in fetch_build_egg
raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['/usr/local/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp2nz6gige', '--quiet', 'numpy<1.24,>=1.11']' returned non-zero exit status 1.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
我想可能安装numba需要gcc来编译源代码,而alpine默认没有gcc。有可能在alpine中安装依赖关系吗?我该怎么做才能成功呢?我应该在基本容器中安装gcc吗?我还是想保持苗条的形象。这是我的python依赖项:
fastapi==0.95.0
openai==0.27.0
sse-starlette==1.3.3
SQLAlchemy~=1.4.6
pydantic~=1.10.5
rembg==2.0.32
Pillow==9.5.0
aiohttp==3.8.4
aiosignal==1.3.1
anyio==3.6.2
async-timeout==4.0.2
asyncer==0.0.2
attrs==22.2.0
certifi==2022.12.7
charset-normalizer==3.1.0
click==8.1.3
coloredlogs==15.0.1
filetype==1.2.0
flatbuffers==23.3.3
frozenlist==1.3.3
h11==0.14.0
httptools==0.5.0
humanfriendly==10.0
idna==3.4
ImageHash==4.3.1
imageio==2.27.0
lazy_loader==0.2
llvmlite==0.39.1
mpmath==1.3.0
multidict==6.0.4
networkx==3.1
numba==0.56.4
numpy==1.24.2
onnxruntime==1.14.1
opencv-python-headless==4.7.0.72
packaging==23.0
Pillow==9.5.0
platformdirs==3.2.0
pooch==1.7.0
protobuf==4.22.1
pydantic==1.10.7
PyMatting==1.1.8
python-dotenv==1.0.0
python-multipart==0.0.6
PyWavelets==1.4.1
PyYAML==6.0
rembg==2.0.32
requests==2.28.2
scikit-image==0.20.0
scipy==1.10.1
sniffio==1.3.0
starlette==0.26.1
sympy==1.11.1
tifffile==2023.3.21
tqdm==4.65.0
typing_extensions==4.5.0
urllib3==1.26.15
uvicorn==0.21.1
uvloop==0.17.0
watchdog==3.0.0
watchfiles==0.19.0
websockets==11.0
yarl==1.8.2
psycopg2-binary==2.9.6
您可以尝试创建一个单独的容器,其中包含您可能需要的所有构建工具,然后使用它来编译所需的包:
FROM alpine:latest as builder
RUN apk add --no-cache gcc musl-dev
FROM python:3.10-alpine
COPY --from=builder /usr/bin/gcc /usr/bin/
COPY --from=builder /usr/lib/gcc /usr/lib/gcc
RUN apk add --no-cache libstdc++
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
这将创建两个阶段:在第一阶段,它安装gcc
和musl-dev
并构建中间映像。在第二阶段,它从中间映像复制必要的文件,并安装libstdc++
和Python依赖项。这确保了最终的映像保持精简,并且不包含任何不必要的构建工具或依赖项。