【问题标题】:DockerSkeleton python ML module installation errorDockerSkeleton python ML模块安装错误
【发布时间】:2018-09-04 21:30:59
【问题描述】:

我正在尝试通过 dockerSkeleton 安装 python ml 模块,以便我可以从 openwhisk cli 调用 docker 操作,但我不断遇到错误并且找不到太多帮助。

  Collecting scikit-learn (from sklearn->-r requirements.txt (line 4))
    Downloading https://files.pythonhosted.org/packages/25/b6    /454cf208be93efa3db50ce06b732328c57ede005d1dcfa71d9a1548530b0/scikit-learn-0.19.2.tar.gz (9.7MB)
    Building wheels for collected packages: numpy, elm, scipy, sklearn, deap, optunity, scikit-learn
    Running setup.py bdist_wheel for numpy: started
    Running setup.py bdist_wheel for numpy: still running...
  Running setup.py bdist_wheel for numpy: still running...
  Running setup.py bdist_wheel for numpy: still running...
  Running setup.py bdist_wheel for numpy: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/29/74/5c/331da973b82cedd300e088ad58bd241c4c8857dd6faf5433eb
  Running setup.py bdist_wheel for elm: started
  Running setup.py bdist_wheel for elm: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/31/17/21/20fd245c9d2b1db0e4805d9e3a9b36c2767ce4816378548cf7
  Running setup.py bdist_wheel for scipy: started
  Running setup.py bdist_wheel for scipy: finished with status 'error'
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-jprwp998/scipy/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-st6v_gb2 --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-jprwp998/scipy/setup.py", line 474, in <module>
      setup_package()
    File "/tmp/pip-install-jprwp998/scipy/setup.py", line 450, in setup_package
      from numpy.distutils.core import setup
  ModuleNotFoundError: No module named 'numpy'

  ----------------------------------------
  Failed building wheel for scipy
  Running setup.py clean for scipy
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-jprwp998/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:

  `setup.py clean` is not supported, use one of the following instead:

    - `git clean -xdf` (cleans all files)
    - `git clean -Xdf` (cleans all versioned files, doesn't touch
                        files that aren't checked into the git repo)

  Add `--force` to your command to use it anyway if you must (unsupported).


  ----------------------------------------
  Failed cleaning build dir for scipy
  Running setup.py bdist_wheel for sklearn: started
  Running setup.py bdist_wheel for sklearn: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/76/03/bb/589d421d27431bcd2c6da284d5f2286c8e3b2ea3cf1594c074
  Running setup.py bdist_wheel for deap: started
  Running setup.py bdist_wheel for deap: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/22/ea/bf/dc7c8a2262025a0ab5da9ef02282c198be88902791ca0c6658
  Running setup.py bdist_wheel for optunity: started
  Running setup.py bdist_wheel for optunity: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/1c/a1/79/8c2f85ed743981107a5b98afcc95bab74d5f85335ec70c7995
  Running setup.py bdist_wheel for scikit-learn: started
  Running setup.py bdist_wheel for scikit-learn: finished with status 'error'
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-jprwp998/scikit-learn/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-mhy2zrpk --python-tag cp36:
  Partial import of sklearn during the build process.
  Traceback (most recent call last):
    File "/tmp/pip-install-jprwp998/scikit-learn/setup.py", line 168, in get_numpy_status
      import numpy
  ModuleNotFoundError: No module named 'numpy'
  Traceback (most recent call last):
    File "/tmp/pip-install-jprwp998/scikit-learn/setup.py", line 148, in get_scipy_status
      import scipy
  ModuleNotFoundError: No module named 'scipy'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-jprwp998/scikit-learn/setup.py", line 269, in <module>
      setup_package()
    File "/tmp/pip-install-jprwp998/scikit-learn/setup.py", line 249, in setup_package
      .format(numpy_req_str, instructions))
  ImportError: Numerical Python (NumPy) is not installed.
  scikit-learn requires NumPy >= 1.8.2.
  Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html


  ----------------------------------------
  Failed building wheel for scikit-learn
  Running setup.py clean for scikit-learn

我用来构建它的 docker 文件是

# Dockerfile for Python whisk docker action
FROM openwhisk/dockerskeleton

ENV FLASK_PROXY_PORT 8080


# lapack-dev is available in community repo.
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories

# add package build dependencies
RUN apk add --no-cache \
        g++ \
        lapack-dev \
        gfortran


# Install our action's Python dependencies
ADD requirements.txt /action/requirements.txt
RUN cd /action; pip install -r requirements.txt

# Add all source assets
ADD . /action
# Rename our executable Python action

ADD main.py /action/exec


CMD ["/bin/bash", "-c", "cd actionProxy && python -u actionproxy.py"]

需求文件是

numpy==1.14.3
elm
scipy
sklearn

我搜索了很多网站,但没有任何帮助,如果有人对 openwhisk docker python 操作有任何想法或经验,请提供任何帮助。

我已经通过安装 numpy 进行了检查,并且它工作正常,但是当我同时添加 scipy 和 numpy 来安装它时,我会抛出找不到 numpy 模块的错误。

谢谢

【问题讨论】:

    标签: python python-3.x python-2.7 dockerfile openwhisk


    【解决方案1】:

    尝试使用 python 运行时类型python-jessie:3 它已经包含一些与机器学习相关的包,例如 numpy、scipy、pandas 和 scikit-learn

    例如使用 CLI 创建操作

    ibmcloud fn action update mymlaction mymlaction.py --kind python-jessie:3
    

    这里有更多关于 python 运行时的细节https://console.bluemix.net/docs/openwhisk/openwhisk_reference.html#openwhisk_ref_python_environments

    【讨论】:

    • 我使用的是开源发行版而不是 ibm 的
    • 并且 dsitribution 没有 python-jessie:3 无法创建操作“测试”:请求内容格式错误:种类 'python-jessie:3' 不在 Set(php:7.1, swift: 4.1, ruby​​:2.5, nodejs:8, swift:3, nodejs, blackbox, java, sequence, nodejs:6, php:7.2, python:3, python, python:2, swift, swift:3.1.1)跨度>
    • @waqar 看看这个 Dockerfile 关于如何创建你自己的 docker 镜像,然后你可以在你的 docker 操作中使用github.com/ibm-functions/runtime-python/blob/master/python3.7/… requirements.txt 包括一些 ml 包
    猜你喜欢
    • 1970-01-01
    • 2013-08-12
    • 2022-01-11
    • 1970-01-01
    • 2015-03-12
    • 2016-06-11
    • 1970-01-01
    • 2016-03-14
    • 1970-01-01
    相关资源
    最近更新 更多