Python 如何安装 scipy misc 包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30720760/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install scipy misc package
提问by javadba
I have installed (actually reinstalled) scipy:
我已经安装(实际上是重新安装)scipy:
10_x86_64.whl (19.8MB): 19.8MB downloaded
Installing collected packages: scipy
Successfully installed scipy
But the misc subpackage is apparently not included?
但是 misc 子包显然不包括在内?
16:03:28/shared $ipython
In [1]: from scipy.misc import imread
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-f9d3d927b58f> in <module>()
----> 1 from scipy.misc import imread
ImportError: cannot import name imread
What is the way to install the scipy.misc package?
scipy.misc 包的安装方式是什么?
采纳答案by maxymoo
I think you need to install PIL as well. From the scipy.misc docs:
我认为您还需要安装 PIL。从scipy.misc 文档:
Note that the Python Imaging Library (PIL) is not a dependency of SciPy and therefore the pilutil module is not available on systems that don't have PIL installed.
请注意,Python Imaging Library (PIL) 不是 SciPy 的依赖项,因此 pilutil 模块在未安装 PIL 的系统上不可用。
回答by gemesyscanada
I had same problem, running Python 2.7.12 on an old Windows XP/SP3 box. I had some stuff running on Python on MacBook, and wanted to make it work on an old Windows box. It canbe done. The winbox had pip ver. 8, and I upgraded it to pip ver. 9, from within Python, using the suggestion pip provides when you run it. I had installed numpy and Pillow (current ver of PIL), using "pip install numpy" and "pip install Pillow", but "pip install scipy" and "pip install scipy.misc" failed with "no matching distribution found". I had to uninstall numpy, and then install two files: 1) numpy+mkl and then 2) scipy, both files installed are binaries for Windows, in .whl (wheel) archive format, downloaded from: http://www.lfd.uci.edu/~gohlke/pythonlibs/site maitained by Christoph Gohlke. Find the binary versions you need for your flavour of Windows, and downloaded them into C:\some\directory. Installation order is important. First the numpy+mkl is installed, using pip, with the scipy file second. I downloaded the files from Gohlke's site, and then used pip to install them. For my old winbox, this was:
我有同样的问题,在旧的 Windows XP/SP3 机器上运行 Python 2.7.12。我在 MacBook 上的 Python 上运行了一些东西,并想让它在旧的 Windows 机器上运行。它可以完成。winbox 有 pip 版本。8,我把它升级到 pip 版本。9,在 Python 中,使用运行时 pip 提供的建议。我已经安装了 numpy 和 Pillow(PIL 的当前版本),使用“pip install numpy”和“pip install Pillow”,但是“pip install scipy”和“pip install scipy.misc”因“找不到匹配的发行版”而失败。我不得不卸载 numpy,然后安装两个文件:1)numpy+mkl 然后 2)scipy,安装的两个文件都是 Windows 的二进制文件,采用 .whl(wheel)存档格式,从:http://www.lfd .uci.edu/~gohlke/pythonlibs/网站由 Christoph Gohlke 维护。找到您的 Windows 风格所需的二进制版本,并将它们下载到 C:\some\directory。安装顺序很重要。首先使用 pip 安装 numpy+mkl,然后安装 scipy 文件。我从 Gohlke 的站点下载了这些文件,然后使用 pip 安装它们。对于我的旧 winbox,这是:
C:\some\directory\> pip install numpy-1.12.1rc1+mkl-cp27-cp27m-win32.whl
(you should see)
(你应该看到)
Installing collected packages: numpy
Successfully installed numpy-1.12.1rc1+mkl
(then, you can run)
(然后,你可以运行)
C:\some\directory\> pip install scipy-0.18.1-cp27-cp27m-win32.whl
and you should see the "Successfully installed..." message. I had already installed Pillow. Confirm by starting Python, and trying:
您应该会看到“已成功安装...”消息。我已经安装了 Pillow。通过启动 Python 进行确认,然后尝试:
>>> import numpy as np
>>> from PIL import Image, ImageDraw
>>> import scipy.misc
and all these should work. You should be able to render a .jpg with:
所有这些都应该有效。您应该能够使用以下内容渲染 .jpg:
image = Image.open("Somefile.jpg")
image.show()
and your somefile.jpg will be displayed.
并且您的 somefile.jpg 将被显示。