Importerror cannot import name imread

Решил попробовать инструмент WEB тестирования.
Выбор пал на Selenium для python.

выполнил инсталляцию пакета pip install selenium
selenium (3.4.0)

запустил selenium server на localhost

I’ve seen this problem before with other people, but haven’t found a fix.

All I’m trying to do is:

from scipy.misc import imread

But it’s fine when I do from pilutil import * on its own (no import error). Even . /site-packages/scipy/misc/pilutil.py exists so I’ve got no idea why this is failing.

7 Answers 7

You might need to install PIL or Pillow.

If you have Pillow installed with scipy and it is still giving you error then check your scipy version because it has been removed from scipy since 1.3.0rc1 .

rather install scipy 1.1.0 by :

pip install scipy==1.1.0

The method imread in scipy.misc requires the forked package of PIL named Pillow . If you are having problem installing the right version of PIL try using imread in other packages:

To read jpg images without PIL use:

You can try from scipy.misc.pilutil import imread instead of from scipy.misc import imread

Please check the GitHub page : https://github.com/amueller/mglearn/issues/2 for more details.

looking into the documentation it says scipy.misc.imread is deprecated. It says to install imageio, and to use imageio.imread instead. Works great!

Expanding on Naeem’s answer

If you want to work with a scipy version that is higher than 1.3.0 then, as instructed in the scipy’s documentation of the imread function, we can use the imageio module instead.

To successfully use the imageio imread function in a way that replicates the functionality of scipy’s imread you can follow the instructions described here (disclaimer: I haven’t yet tried it myself yet)

I received errors when trying to use

I was able to remove the errors and use the above line by first installing numpy+mkl and then installing scipy from Christoph Gohlke’s website.

For me this was:

You will need to pick the correct version of the whl’s for your system.

Also, make sure the pip command installs the modules. If you have any 1 or more of these already installed, you might need to use pip to force a reinstall.

Comments

Copy link Quote reply

rmrfslashbin commented Mar 6, 2019

When running this step:
]$ python setup.py
Traceback (most recent call last):
File "setup.py", line 6, in
import terrain
File "/home/rsigler/src/neural-mmo/neural-mmo/terrain.py", line 7, in
from scipy.misc import imread, imsave
ImportError: cannot import name ‘imread’ from ‘scipy.misc’ (/usr/local/anaconda2/envs/python3/lib/python3.7/site-packages/scipy/misc/init.py)

]$ ipython
Python 3.7.2 (default, Dec 29 2018, 06:19:36)
Type ‘copyright’, ‘credits’ or ‘license’ for more information
IPython 7.2.0 — An enhanced Interactive Python. Type ‘?’ for help.

Оцените статью
Много толка
Добавить комментарий