How do I install scipy and numpy with setuptools

梦想的初衷 提交于 2020-02-04 02:44:26

问题


I am developing a python 3.4 module which has scipy and numpy as dependencies. So I declared them in my setup.py under install_requires.

Here is the minimum running example of my setup.py

from setuptools import setup

setup(
        name='MyModule',
        version='1.0.5',
        author='Alexander Mueller',
        packages=[],
        scripts=[],
        license='LICENSE.txt',
        description='Stuff',
        install_requires=[
            "pandas == 0.15.2",
            "scikit-learn==0.17",
            "seaborn == 0.5.1",
            "scipy == 0.17.0",
            "numpy==1.10.4"
        ]
)

While running python setup.py install the following exception occurs.

However, when I install all those packages in order with pip install, no error occurs at all. Might be easy_install the problem?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 16, in <module>
    "numpy==1.10.4"
  File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/install.py", line 117, in do_egg_install
    cmd.run()
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 380, in run
    self.easy_install(spec, not self.no_deps)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 610, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 661, in install_item
    self.process_distribution(spec, dist, deps)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 709, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/pkg_resources/__init__.py", line 830, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1075, in best_match
    return self.obtain(req, installer)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1087, in obtain
    return installer(requirement)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 629, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 659, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 842, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 1070, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 1056, in run_setup
    run_setup(setup_script, args)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 240, in run_setup
    raise
  File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 193, in setup_context
    yield
  File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 164, in save_modules
    saved_exc.resume()
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 139, in resume
    compat.reraise(type, exc, self._tb)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/compat.py", line 65, in reraise
    raise value.with_traceback(tb)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 152, in save_modules
    yield saved
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 193, in setup_context
    yield
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 237, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 267, in run
    return func()
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 236, in runner
    _execfile(setup_script, ns)
  File "/Users/alexandermueller/.virtualenvs/fpm_test3/lib/python3.4/site-packages/setuptools/sandbox.py", line 46, in _execfile
    exec(code, globals, locals)
  File "/var/folders/b0/_y4bfk6x4bldrmtycxhmbtrm0000gn/T/easy_install-drrk1iwn/scipy-0.17.0/setup.py", line 265, in <module>
  File "/var/folders/b0/_y4bfk6x4bldrmtycxhmbtrm0000gn/T/easy_install-drrk1iwn/scipy-0.17.0/setup.py", line 253, in setup_package
ImportError: No module named 'numpy'

Thank you guys in advance.


回答1:


Order seems to matter here, with this order the required packages were installed

install_requires=[
            "numpy == 1.10.4",
            "pandas == 0.15.2",
            "seaborn == 0.5.1",
            "scipy == 0.17.0",
            "scikit-learn == 0.17"
        ]

Tested with pip3 1.5.4, xubuntu 14.04



来源:https://stackoverflow.com/questions/35055569/how-do-i-install-scipy-and-numpy-with-setuptools

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