我使用OS X Yosemite和Homebrew安装的Python 3.5。
尝试使用pip3 install numpy
安装NumPy会导致以下错误
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/setup.py", line 251, in <module>
setup_package()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/setup.py", line 243, in setup_package
setup(**metadata)
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/install.py", line 62, in run
r = self.setuptools_run()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/install.py", line 36, in setuptools_run
return distutils_install.run(self)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/command/install.py", line 539, in run
self.run_command('build')
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build.py", line 39, in run
old_build.run(self)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build_src.py", line 153, in run
self.build_sources()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build_src.py", line 170, in build_sources
self.build_extension_sources(ext)
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build_src.py", line 329, in build_extension_sources
sources = self.generate_sources(sources, ext)
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 432, in generate_config_h
moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
File "numpy/core/setup.py", line 42, in check_types
out = check_types(*a, **kw)
File "numpy/core/setup.py", line 293, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
显然无法找到Python.h
,但/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m/Python.h
@Controller
@RequestMapping("/main")
public class MainController {
private static Logger LOGGER = Logger.getLogger("Controller");
@Autowired
private UserService userService;
@RequestMapping(value = "/users" , method = RequestMethod.GET)
public String getUsers(Model model) {
LOGGER.debug("Receive request for show all users");
List<User> users = userService.getAll();
model.addAttribute("users", users);
return "userspage";
}
@RequestMapping(value = "/users/add", method = RequestMethod.GET)
public String getAdd() {
LOGGER.debug("Receive request to show add page");
return "addpage";
}
@RequestMapping(value = "/users/add", method = RequestMethod.POST)
public String add(@ModelAttribute("userAttribute") User user) {
LOGGER.debug("Recieve request to add a new user");
userService.add(user);
return "addedpage";
}
@RequestMapping(value = "/users/delete", method = RequestMethod.GET)
public String delete(@RequestParam(value = "id", required = true)Integer
id, Model model) {
LOGGER.debug("Recieve request for deleting user");
userService.delete(id);
model.addAttribute("id", id);
return "deletedpage";
}
@RequestMapping(value = "/users/edit", method = RequestMethod.GET)
public String getEdit(@RequestParam(value = "id", required = true)Integer
id, Model model) {
LOGGER.debug("Recieve request to show editpage");
model.addAttribute("userAttribute", userService.get(id));
return "editpage";
}
@RequestMapping(value = "/users/edit", method = RequestMethod.POST)
public String saveEdit(@ModelAttribute("userAttribute") User user,
@RequestParam(value = "id", required =
true)Integer id, Model model) {
LOGGER.debug("Received request to update person");
user.setId(id);
userService.edit(user);
model.addAttribute("id", id);
return "editedpage";
}
@RequestMapping(value = "/users/actions", method = RequestMethod.GET)
public String getActionsOfUser(@RequestParam(value = "id", required =
true)Integer id, Model model, User user){
LOGGER.debug("Recieve request to show user Action");
model.addAttribute("userId", userService.get(id));
model.addAttribute("userAction", userService.getListOfActions(user));
return "userActionsPage";
}
}
我该怎么做?
答案 0 :(得分:2)
这是一个已知错误,应尽快解决: https://github.com/Homebrew/homebrew/issues/43916
答案 1 :(得分:0)
SystemError:无法编译&#39; Python.h&#39;。也许你需要安装python-dev | python-devel。
尝试安装python开发库。
答案 2 :(得分:0)
我遇到了同样的问题。
以下帮助了我:
下载(使用您的浏览器)并安装miniconda for python35(在我的情况下为64位)。参见:
http://conda.pydata.org/miniconda.html
使下载的脚本可执行
chmod 777 <scriptname>
并以适当的权限运行它。
使用
安装numpyconda install numpy
再次使用适当的权限。
而不是sudo'ing一切,sudo xterm和从那里工作。