linux里找python包,python - 高山Linux:已安装软件包,但未找到模块 - 堆栈内存溢出...

我正在为数据科学项目构建docker映像。

我通过RUN apk add 安装核心依赖RUN apk add 。

Dockerfile-dev的

FROM python:3.6-alpine

#SOFTWARE PACKAGES

ENV PACKAGES="\

dumb-init \

musl \

libc6-compat \

linux-headers \

build-base \

bash \

git \

ca-certificates \

freetype \

libgfortran \

libgcc \

libstdc++ \

openblas \

tcl \

tk \

libssl1.0 \

"

# PYTHON DATA SCIENCE PACKAGES

ENV PYTHON_PACKAGES="\

numpy \

matplotlib \

scipy \

scikit-learn \

pandas \

nltk \

"

RUN apk add --no-cache --virtual build-dependencies python3 \

&& apk add --virtual build-runtime \

build-base python3-dev openblas-dev freetype-dev pkgconfig gfortran \

&& ln -s /usr/include/locale.h /usr/include/xlocale.h \

&& python3 -m ensurepip \

&& rm -r /usr/lib/python*/ensurepip \

&& pip3 install --upgrade pip setuptools \

&& ln -sf /usr/bin/python3 /usr/bin/python \

&& ln -sf pip3 /usr/bin/pip \

&& rm -r /root/.cache \

&& pip install --no-cache-dir $PYTHON_PACKAGES \

&& apk del build-runtime \

&& apk add --no-cache --virtual build-dependencies $PACKAGES \

&& rm -rf /var/cache/apk/*

# add and install requirements

COPY ./requirements.txt /usr/src/app/requirements.txt

RUN pip install -r requirements.txt

一切都建立在pandas ,这时出现了这个错误:

Complete output from command python setup.py egg_info:

Traceback (most recent call last):

File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 359, in get_provider

module = sys.modules[moduleOrReq]

KeyError: 'numpy'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "", line 1, in

File "/tmp/pip-install-v7gyw8y_/pandas/setup.py", line 732, in

ext_modules=maybe_cythonize(extensions, compiler_directives=directives),

File "/tmp/pip-install-v7gyw8y_/pandas/setup.py", line 475, in maybe_cythonize

numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')

File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1144, in resource_filename

return get_provider(package_or_requirement).get_resource_filename(

File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 361, in get_provider

__import__(moduleOrReq)

ModuleNotFoundError: No module named 'numpy'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-v7gyw8y_/pandas/

但是预先安装了numpy HAD:

运行numpy的setup.py install:状态为“完成”

尚未击败,我将pandas==0.20.3 (此版本在我的py36 env中运行)移至requirements.txt ,并安装了它,如日志所示:

Successfully built: pandas

Installing collected packages: pandas

Successfully installed: pandas-0.20.3

但是,在构建时间之后,运行容器会记录以下错误:

users_1 | File "/usr/src/app/project/api/classifiers/metadata/learn.py", line 14, in

users_1 | import pandas as pd

users_1 | ModuleNotFoundError: No module named 'pandas'

所以它是通过pip安装的,但是找不到?

如何通过RUN apk add安装pandas ,以保持数据科学项目的构建一致性?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值