成功解决ModuleNotFoundError: No module named engine

举报
一个处女座的程序猿 发表于 2021/03/27 01:25:00 2021/03/27
【摘要】 成功解决ModuleNotFoundError: No module named 'engine'     目录 解决问题 解决思路 解决方法       解决问题 ModuleNotFoundError: No module named 'engine'     解决思路 ...

成功解决ModuleNotFoundError: No module named 'engine'

 

 

目录

解决问题

解决思路

解决方法


 

 

 

解决问题

ModuleNotFoundError: No module named 'engine'

 

 

解决思路

找不到模块错误:没有名为“engine”的模块

 

 

解决方法

相关文章
Py之pyttsx:pyttsx/pyttsx3的简介、安装、使用方法之详细攻略


  
  1. def init Found at: pyttsx.__init__
  2. def init(driverName=None, debug=False):
  3. '''
  4. Constructs a new TTS engine instance or reuses the existing instance for
  5. the driver name.
  6. @param driverName: Name of the platform specific driver to use. If
  7. None, selects the default driver for the operating system.
  8. @type: str
  9. @param debug: Debugging output enabled or not
  10. @type debug: bool
  11. @return: Engine instance
  12. @rtype: L{engine.Engine}
  13. '''
  14. try:
  15. eng = _activeEngines[driverName]
  16. except KeyError:
  17. eng = Engine(driverName, debug)
  18. _activeEngines[driverName] = eng
  19. return eng
  20. class WeakValueDictionary(collections.MutableMapping):
  21. """Mapping class that references values weakly.
  22. Entries in the dictionary will be discarded when no strong
  23. reference to the value exists anymore
  24. """
  25. # We inherit the constructor without worrying about the input
  26. # dictionary; since it uses our .update() method, we get the right
  27. # checks (if the other dictionary is a WeakValueDictionary,
  28. # objects are unwrapped on the way out, and we always wrap on the
  29. # way in).
  30. def __init__(*args, **kw):
  31. if not args:
  32. raise TypeError("descriptor '__init__' of 'WeakValueDictionary' "
  33. "object needs an argument")
  34. self, *args = args
  35. if len(args) > 1:
  36. raise TypeError('expected at most 1 arguments, got %d' % len(args))
  37. def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
  38. self = selfref()
  39. if self is not None:
  40. if self._iterating:
  41. self._pending_removals.append(wr.key)
  42. else:
  43. # Atomic removal is necessary since this function
  44. # can be called asynchronously by the GC
  45. _atomic_removal(d, wr.key)
  46. self._remove = remove
  47. # A list of keys to be removed
  48. self._pending_removals = []
  49. self._iterating = set()
  50. self.data = d = {}
  51. self.update(*args, **kw)
  52. def _commit_removals(self):
  53. l = self._pending_removals
  54. d = self.data
  55. # We shouldn't encounter any KeyError, because this method should
  56. # always be called *before* mutating the dict.
  57. while l:
  58. key = l.pop()
  59. _remove_dead_weakref(d, key)
  60. def __getitem__(self, key):
  61. if self._pending_removals:
  62. self._commit_removals()
  63. o = self.data[key]()
  64. if o is None:
  65. raise KeyError(key)
  66. else:
  67. return o
  68. def __delitem__(self, key):
  69. if self._pending_removals:
  70. self._commit_removals()
  71. del self.data[key]
  72. def __len__(self):
  73. if self._pending_removals:
  74. self._commit_removals()
  75. return len(self.data)
  76. def __contains__(self, key):
  77. if self._pending_removals:
  78. self._commit_removals()
  79. try:
  80. o = self.data[key]()
  81. except KeyError:
  82. return False
  83. return o is not None
  84. def __repr__(self):
  85. return "<%s at %#x>" % (self.__class__.__name__, id(self))
  86. def __setitem__(self, key, value):
  87. if self._pending_removals:
  88. self._commit_removals()
  89. self.data[key] = KeyedRef(value, self._remove, key)
  90. def copy(self):
  91. if self._pending_removals:
  92. self._commit_removals()
  93. new = WeakValueDictionary()
  94. for key, wr in self.data.items():
  95. o = wr()
  96. if o is not None:
  97. new[key] = o
  98. return new
  99. __copy__ = copy
  100. def __deepcopy__(self, memo):
  101. from copy import deepcopy
  102. if self._pending_removals:
  103. self._commit_removals()
  104. new = self.__class__()
  105. for key, wr in self.data.items():
  106. o = wr()
  107. if o is not None:
  108. new[deepcopy(key, memo)] = o
  109. return new
  110. def get(self, key, default=None):
  111. if self._pending_removals:
  112. self._commit_removals()
  113. try:
  114. wr = self.data[key]
  115. except KeyError:
  116. return default
  117. else:
  118. o = wr()
  119. if o is None:
  120. # This should only happen
  121. return default
  122. else:
  123. return o
  124. def items(self):
  125. if self._pending_removals:
  126. self._commit_removals()
  127. with _IterationGuard(self):
  128. for k, wr in self.data.items():
  129. v = wr()
  130. if v is not None:
  131. yield k, v
  132. def keys(self):
  133. if self._pending_removals:
  134. self._commit_removals()
  135. with _IterationGuard(self):
  136. for k, wr in self.data.items():
  137. if wr() is not None:
  138. yield k
  139. __iter__ = keys
  140. def itervaluerefs(self):
  141. """Return an iterator that yields the weak references to the values.
  142. The references are not guaranteed to be 'live' at the time
  143. they are used, so the result of calling the references needs
  144. to be checked before being used. This can be used to avoid
  145. creating references that will cause the garbage collector to
  146. keep the values around longer than needed.
  147. """
  148. if self._pending_removals:
  149. self._commit_removals()
  150. with _IterationGuard(self):
  151. yield from self.data.values()
  152. def values(self):
  153. if self._pending_removals:
  154. self._commit_removals()
  155. with _IterationGuard(self):
  156. for wr in self.data.values():
  157. obj = wr()
  158. if obj is not None:
  159. yield obj
  160. def popitem(self):
  161. if self._pending_removals:
  162. self._commit_removals()
  163. while True:
  164. key, wr = self.data.popitem()
  165. o = wr()
  166. if o is not None:
  167. return key, o
  168. def pop(self, key, *args):
  169. if self._pending_removals:
  170. self._commit_removals()
  171. try:
  172. o = self.data.pop(key)()
  173. except KeyError:
  174. o = None
  175. if o is None:
  176. if args:
  177. return args[0]
  178. else:
  179. raise KeyError(key)
  180. else:
  181. return o
  182. def setdefault(self, key, default=None):
  183. try:
  184. o = self.data[key]()
  185. except KeyError:
  186. o = None
  187. if o is None:
  188. if self._pending_removals:
  189. self._commit_removals()
  190. self.data[key] = KeyedRef(default, self._remove, key)
  191. return default
  192. else:
  193. return o
  194. def update(*args, **kwargs):
  195. if not args:
  196. raise TypeError("descriptor 'update' of 'WeakValueDictionary' "
  197. "object needs an argument")
  198. self, *args = args
  199. if len(args) > 1:
  200. raise TypeError('expected at most 1 arguments, got %d' % len(args))
  201. dict = args[0] if args else None
  202. if self._pending_removals:
  203. self._commit_removals()
  204. d = self.data
  205. if dict is not None:
  206. if not hasattr(dict, "items"):
  207. dict = type({})(dict)
  208. for key, o in dict.items():
  209. d[key] = KeyedRef(o, self._remove, key)
  210. if len(kwargs):
  211. self.update(kwargs)
  212. def valuerefs(self):
  213. """Return a list of weak references to the values.
  214. The references are not guaranteed to be 'live' at the time
  215. they are used, so the result of calling the references needs
  216. to be checked before being used. This can be used to avoid
  217. creating references that will cause the garbage collector to
  218. keep the values around longer than needed.
  219. """
  220. if self._pending_removals:
  221. self._commit_removals()
  222. return list(self.data.values())

 

 

 

 

 

文章来源: yunyaniu.blog.csdn.net,作者:一个处女座的程序猿,版权归原作者所有,如需转载,请联系作者。

原文链接:yunyaniu.blog.csdn.net/article/details/84947123

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。