簡體   English   中英

pip install pyopencl 失敗並顯示 ImportError: No module named 'numpy'

[英]pip install pyopencl fails with ImportError: No module named 'numpy'

使用 pip 安裝 pyopencl 時,它會抱怨缺少 numpy:

Collecting pyopencl
Downloading https://files.pythonhosted.org/packages/bc/58/3ab1246e94986f1b6953e76d7ea7e69d2dbfef7b3f3874eded48524a024f/pyopencl-2018.2.2.tar.gz (341kB)
    100% |████████████████████████████████| 348kB 9.5MB/s 
    Complete output from command python setup.py egg_info:
    ---------------------------------------------------------------------------
    Pybind11 is not installed.
    ---------------------------------------------------------------------------
    Very likely, the build process after this message will fail.

    Simply press Ctrl+C and type
    python -m pip install pybind11
    to fix this. If you don't, the build will continue
    in a few seconds.

    [1] https://pybind11.readthedocs.io/en/stable/
    ---------------------------------------------------------------------------
    Continuing in 1 seconds...    
    ---------------------------------------------------------------------------
    Mako is not installed.
    ---------------------------------------------------------------------------
    That is not a problem, as most of PyOpenCL will be just fine
    without it. Some higher-level parts of pyopencl (such as
    pyopencl.reduction) will not function without the templating engine
    Mako [1] being installed. If you would like this functionality to
    work, you might want to install Mako after you finish
    installing PyOpenCL.

    Simply type
    python -m pip install mako
    either now or after the installation completes to fix this.

    [1] http://www.makotemplates.org/
    ---------------------------------------------------------------------------
    Hit Ctrl-C now if you'd like to think about the situation.
    ---------------------------------------------------------------------------
    Continuing in 1 seconds...   
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-nccshu4t/pyopencl/setup.py", line 353, in <module>
        main()
    File "/tmp/pip-install-nccshu4t/pyopencl/setup.py", line 320, in main
        language='c++',
    File "/tmp/pip-install-nccshu4t/pyopencl/aksetup_helper.py", line 41, in __init__
        self._include_dirs = self.include_dirs
    File "/tmp/pip-install-nccshu4t/pyopencl/aksetup_helper.py", line 55, in get_include_dirs
        return self._include_dirs + self.get_additional_include_dirs()
    File "/tmp/pip-install-nccshu4t/pyopencl/aksetup_helper.py", line 52, in get_additional_include_dirs
        return [self.get_numpy_incpath()]
    File "/tmp/pip-install-nccshu4t/pyopencl/aksetup_helper.py", line 47, in get_numpy_incpath
        file, pathname, descr = find_module("numpy")
    File "/home/app/nb-ocl/.venv/lib/python3.5/imp.py", line 296, in find_module
        raise ImportError(_ERR_MSG.format(name), name=name)
    ImportError: No module named 'numpy'

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

這是 PyPI 中發布的最新版本 pyopencl 的問題。 github repo 中的最新版本已經解決了這個問題,在 setup.py::setup() 中使用了新的ExtensionUsingNumpy而不是舊的NumpyExtension

盡管如此,如果沒有安裝 Mako 和 pybind11 依賴項,pyopencl 的安裝將失敗。 為什么 setup.py/setuptools 不處理這些?

由於 PyPI 中沒有可用的二進制文件(輪子),pip install 默認會拉取軟件分發 (sdist) 存檔並嘗試構建它。 pyopencl 的構建過程依賴於 numpy、pybind11 和 mako,因此 pip 失敗。

OTOH 如果 pyopencl 提供二進制文件(輪子),這個問題可以被規避。 有一個等待審查的拉取請求應該有助於解決這個問題: https : //github.com/inducer/pyopencl/pull/264

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM