attributeerror 模块 'time' 没有属性 'clock' (pyqt5)

attributeerror module 'time' has no attribute 'clock' (pyqt5)

我知道 time.clock() 自 Python 3.3 以来已被弃用。 但是,当我尝试导入 pyqtgraph 模块时出现错误:

import pyqtgraph 

这是文件中唯一的一行,这是错误:

  File "D:20Backup20Backup\code\Python\PyQt\graphs\first.py", line 1, in <module>
    import pyqtgraph
  File "C:\Users\mpnlo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\__init__.py", line 204, in <module>
    from .graphicsItems.VTickGroup import *
  File "C:\Users\mpnlo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\graphicsItems\VTickGroup.py", line 7, in <module>
    from .. import functions as fn
  File "C:\Users\mpnlo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\functions.py", line 17, in <module>
    from . import debug
  File "C:\Users\mpnlo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\debug.py", line 11, in <module>
    from . import ptime
  File "C:\Users\mpnlo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\ptime.py", line 24, in <module>
    cstart = systime.clock()  ### Required to start the clock in windows
AttributeError: module 'time' has no attribute 'clock'

我想知道是否有人知道这个问题的解决方法,也许是我更新模块中错误的方法,我使用的是最新版本的 pyqtgraph。

安装最新版本pip3 install --upgrade git+http://github.com/pyqtgraph/pyqtgraph.git

如果您遇到这种情况,解决方法是使用集成到 pyqt5 中的 matplotlib 模块,此页面概述了如何执行此操作:

https://pythonspot.com/pyqt5-matplotlib/

希望对您有所帮助!