问题描述
我正在开发一个python 3.4模块,该模块具有scipy和numpy作为依赖项.所以我在install_requires下的setup.py中声明了它们.
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.
这是我的setup.py的最低运行示例.
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"
]
)
在运行 python setup.py install 时,发生以下异常.
While running python setup.py install the following exception occurs.
但是,当我通过pip install顺序安装所有这些软件包时,根本没有发生错误.可能是easy_install问题?
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'
谢谢你们.
推荐答案
这里的顺序似乎很重要,按照此顺序安装了必需的软件包
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"
]
在pip3 1.5.4,xubuntu 14.04中进行了测试
Tested with pip3 1.5.4, xubuntu 14.04
这篇关于如何使用setuptools安装scipy和numpy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!