我已经在python中创建了自己的类,但是在创建对象时却给出了奇怪的错误“ AttributeError:模块'IPython'没有属性'utils'”。此错误来自模块中 init 函数中的import语句。我是从moviepy导入的。
我尝试在类之外编写import语句。我正在尝试制作一个可导入包装以供个人使用。
class video_reader_writer:
def __init__(self,video_file):
from moviepy.editor import ImageSequenceClip // error here
from moviepy.audio.AudioClip import AudioArrayClip
import numpy as np
...
这是堆栈跟踪:
from moviepy.editor import ImageSequenceClip
File "C:\Users\sagar\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\editor.py", line 49, in <module>
from .video.io.html_tools import ipython_display
File "C:\Users\sagar\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\io\html_tools.py", line 20, in <module>
from IPython.display import HTML
File "C:\Users\sagar\AppData\Local\Programs\Python\Python36\lib\site-packages\IPython\__init__.py", line 54, in <module>
from .core.application import Application
File "C:\Users\sagar\AppData\Local\Programs\Python\Python36\lib\site-packages\IPython\core\application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "C:\Users\sagar\AppData\Local\Programs\Python\Python36\lib\site-packages\IPython\core\crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "C:\Users\sagar\AppData\Local\Programs\Python\Python36\lib\site-packages\IPython\core\ultratb.py", line 128, in <module>
import IPython.utils.colorable as colorable
AttributeError: module 'IPython' has no attribute 'utils'