1. import 本地文件出错
from utils.testCases import *
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-1a161c40c5a4> in <module>
----> 1 from utils.testCases import *
ModuleNotFoundError: No module named 'utils'
解决办法:
用pwd查看本地路径:
%pwd
'/Users/houzhizhen/git/opensource/dir1'
用cd命令进入项目的根路径
cd /Users/houzhizhen/git/opensource/project-root
/Users/houzhizhen/git/opensource/project-root
现在可以导入本地的python程序,utils
为本地目录,在/Users/houzhizhen/git/opensource/project-root
下。
from utils.testCases import *
- scipy.misc module has no attribute imread?
>>> import scipy
>>> scipy.misc
<module 'scipy.misc' from 'C:\Python27\lib\site-packages\scipy\misc\__init__.pyc'>
>>> scipy.misc.imread('test.tif')
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
scipy.misc.imread('test.tif')
AttributeError: 'module' object has no attribute 'imread'
- imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use imageio.imread instead.
import imageio
im = imageio.imread('astronaut.png')
im.shape # im is a numpy array
(512, 512, 3)
imageio.imwrite('imageio:astronaut-gray.jpg', im[:, :, 0])
I have some code from my friend. He run it smoothly but I encounter
module scipy.misc has no attribute imresize
I’m searching, installed Pillow (PIL), scipy, scikit,… but dont work
I asked my friend but he forgot what he has installed.
- imresize is deprecated! imresize is deprecated in SciPy 1.0.0, and will be removed in 1.3.0. Use Pillow instead: numpy.array(Image.fromarray(arr).resize()).
from PIL import Image
numpy.array(Image.fromarray(arr).resize())