python notebook 遇到的坑

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 *

  1. 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())
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值