Supplying NumPy site.cfg arguments to pip

后端 未结 4 1891
生来不讨喜
生来不讨喜 2020-12-05 00:34

I\'m using NumPy built against Intel\'s Math Kernel Library. I use virtualenv, and typically use pip to install packages.

However, in order for NumPy to find the

4条回答
  •  清歌不尽
    2020-12-05 01:16

    To your question of how to configure NumPy (e.g. to use OpenBLAS):

    1. Download https://github.com/numpy/numpy/blob/master/site.cfg.example
    2. Edit the relevant lines, e.g.
    [openblas]
    libraries = openblas
    library_dirs = /opt/OpenBLAS/lib
    include_dirs = /opt/OpenBLAS/include
    
    1. Save it as ~/.numpy-site.cfg
    2. Install numpy from source without manually downloading it (--force-reinstall will let it replace an existing package):

      pip install numpy --no-binary numpy --force-reinstall

    3. Bonus: The same file ~/.numpy-site.cfg works for installing scipy on the OpenBLAS:

      pip install scipy --no-binary scipy

      or install them together:

      pip install numpy scipy --no-binary numpy,scipy --force-reinstall

    Sept. 2019: If you're still using Python 2.7, install numpy then install scipy. Attempting to install them together will:

    • invoke a SciPy easy_install installer that requests NumPy,
    • load the latest NumPy installer (even if you specifically asked pip to install numpy==1.14.6 scipy==1.0.1 --no-binary numpy,scipy), then
    • fail with RuntimeError: Python version >= 3.5 required because the latest NumPy does not support Python 2.7.

提交回复
热议问题