Set numpy + pandas as a dependency in setup.py

Installing numpy + pandas via setuptools since the dependency in setup.py does not work for me. This is not about missing dependencies. If I install numpy via pip install numpy and then python setup.py develop , everything works fine. If I understand the right to setuptools documentation, all packages are first built and then installed. Therefore, numpy is created but not installed when pandas .

As a workaround, I added numpy to my setup_requires . This works great, but obviously this is not a very clean solution.

Does anyone know a clean solution (Linux only) for installing numpy + pandas via setuptools?

Update:

Dependency is configured using

 install_requires=['numpy','pandas'] 

It doesn't matter if I add numpy explicitly or just add pandas. In both cases, numpy will load and build, but pandas cannot be created because some headers (which are probably set during the numpy installation, but not during creation) cannot be found. If I install numpy first, everything will be fine. I can reproduce this 100% and regardless of the project I'm working on.

Update 2:

This is the end of the stack trace:

  File "/tmp/easy_install-QMa4ce/pandas-0.14.1/temp/easy_install-f6lreI/numpy-1.9.0/numpy/distutils/command/build_src.py", line 153, in run File "/tmp/easy_install-QMa4ce/pandas-0.14.1/temp/easy_install-f6lreI/numpy-1.9.0/numpy/distutils/command/build_src.py", line 170, in build_sources File "/tmp/easy_install-QMa4ce/pandas-0.14.1/temp/easy_install-f6lreI/numpy-1.9.0/numpy/distutils/command/build_src.py", line 329, in build_extension_sources File "/tmp/easy_install-QMa4ce/pandas-0.14.1/temp/easy_install-f6lreI/numpy-1.9.0/numpy/distutils/command/build_src.py", line 386, in generate_sources File "numpy/core/setup.py", line 432, in generate_config_h File "numpy/core/setup.py", line 42, in check_types entry_points={ File "numpy/core/setup.py", line 293, in check_types SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel. 

The message at the end is finally incorrect. If I do pip install numpy before running python setup.py develop , everything works fine. In the above example, I only had pandas in install_requires and no numpy . But as far as I can understand, it doesn't matter if numpy explicitly added or not.

+6
source share
2 answers

Refer to the open release https://github.com/numpy/numpy/issues/2434 .

This is a known bug in numpy related to setuptools.

As discussed there, use $ pip install -e . , not $ python setup.py develop - the same result, but avoid this problem.

+5
source

They must be declared using install_requires kwarg installation. Here is an example project, geodata, for which pandas is required :

 setup(name='geopandas', version=FULLVERSION, description='Geographic pandas extensions', license='BSD', author='Kelsey Jordahl', author_email=' kjordahl@enthought.com ', url='http://geopandas.org', long_description=LONG_DESCRIPTION, packages=['geopandas', 'geopandas.io', 'geopandas.tools'], install_requires=[ 'pandas', 'shapely', 'fiona', 'descartes', 'pyproj', 'rtree'], # here ) 

You can also specify the required versions, see setuptools docs , since often you want the version to be the latest (has the features / errors you rely on) - here is how I do it in pep8radius .

+3
source

Source: https://habr.com/ru/post/975042/


All Articles