Installing numpy as a dependency with setuptools

眉间皱痕 提交于 2019-11-28 22:56:48

This is a known issue, tracked on numpy/numpy #2434.

I found a workaround for this: add numpy to setup_requires. Having it in both setup_requires and install_requires seems to work fine with the most recent version of setuptools.

So, your setup.py should look something like

setup(
    # Your setup specific stuff here
    setup_requires=["numpy"],  # Just numpy here
    install_requires=["numpy"],  # Add any of your other dependencies here
)

Unless you have access to a binary distribution (pre-compiled/built) for numpy, you'll have to have the python headers available as it needs them to build numpy. This is why most package managers come with pre-compiled versions of these packages. For example you can apt-get install python-numpy, link that into your virtualenv, and when you try to install your program with install_requires=['numpy'] it should see that it's already installed.

To install numpy the setuptools will download the package and compile it from source. However, there are some prerequisites to compile numpy, you can check it here.

_configtest.c:1:20: error: Python.h: No such file or directory

this error indicates that at least you do not have python-dev package installed(if you are using ubuntu/debian).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!