scikit-learn: can't setup.py install without numpy

At minimum, this could use a better error message. Is it not possible to have a project that depends on sklearn and installs all its dependencies to a virtualenv in a single pass? Must I do one pass to install numpy and everything else, and a second pass just to install sklearn?

$ python setup.py install
Partial import of sklearn during the build process.
Traceback (most recent call last):
  File "setup.py", line 154, in <module>
    setup_package()
  File "setup.py", line 146, in setup_package
    from numpy.distutils.core import setup
ImportError: No module named numpy.distutils.core

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 32 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Temporary fix by overriding the install command in setup.py:

import pip
from setuptools import setup
from setuptools.command.install import install
from pip.req import parse_requirements
install_reqs = parse_requirements('./requirements.txt', session=False)
reqs = [str(ir.req) for ir in install_reqs]


class OverrideInstall(install):

    """
    Emulate sequential install of pip install -r requirements.txt
    To fix numpy bug in scipy, scikit in py2
    """

    def run(self):
        for req in reqs:
            pip.main(["install", req])



# the setup
setup(
    ...
    cmdclass={'install': OverrideInstall}
    ....
)

Then run python setup.py install as usual

Various processes at our company involve ‘pip install -r requirements.txt’. This works fine for any group of packages not containing sklearn. I feel certain this isn’t unique to me or my company.

On Fri, May 8, 2015, 4:29 PM Andreas Mueller notifications@github.com wrote:

didn’t @GaelVaroquaux https://github.com/GaelVaroquaux mention a flag to force installing dependencies?

— Reply to this email directly or view it on GitHub https://github.com/scikit-learn/scikit-learn/issues/4164#issuecomment-100393543 .