[Solved] AttributeError: module ‘time’ has no attribute ‘clock’

The time.clock() method has been removed from Python 3.8 or above version. but It works great at Python 3.7 version. if you are using the clock() method in Python 3.8 or above, then you will face AttributeError: module ‘time’ has no attribute ‘clock’.

In this article, we will discuss about this AttributeError: module ‘time’ has no attribute ‘clock’ error in python. And how to resolve the error all the possible solutions with examples.

How AttributeError: module ‘time’ has no attribute ‘clock’ Error Occurs?

I am just run time.clock() method in python 3.8 version but I am getting the error.

AttributeError: module 'time' has no attribute 'clock'

How to fix AttributeError: module ‘time’ has no attribute ‘clock’?

There are different ways to fix this error. Let us take a look at every solution.

Solution 1 – time.clock() has been removed

There are time.clock() has been removed. So that Use below instead of time.clock().

time.perf_counter()

OR

time.process_time()

Solution 2: Use PyCryptodome instead of PyCrypto

If you are using PyCrypto then PyCrypto is dead so you have to uninstall PyCrypto and install PyCryptodome. For the uninstall run this command.

pip3 uninstall PyCrypto

Just use these command to install PyCryptodome.

pip3 install -U PyCryptodome

Now, I hope your error will be gone.

Conclusion

In this article, we have discussed what causes the error and we have discussed ways to fix the error.

we hope this article has been informative. Thank you for reading. Kindly comment and let us know if you found it helpful.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Categories