7

i have a error in python code : 'from time import clock' ImportError: cannot import name 'clock' from 'time' (unknown location)

this not working in python 3.8 can someone help

Ahmad Yhia
  • 71
  • 1
  • 1
  • 5

4 Answers4

13

time.clock is a method that has been deprecated since Python 3.3 and removed from Python 3.8 (see the Python 3.7 time documentation for more information), because its behaviour was dependent on the platform (it behaved differently on Unix compared to Windows). As the documentation suggests, you should use time.perf_counter() or time.process_time() instead. These are subtly different, see this Stack Overflow question for more details.

luuk
  • 1,630
  • 4
  • 12
10

This happens when you use Python 3.8 and passlib version lower than 1.7.2. Try running the command below. This might help.

pip install --upgrade passlib==1.7.2

If you don't have passlib installed, just try

pip install passlib==1.7.2
2

Updating passlib worked for me

pip install passlib==1.7.2
Tobias Windisch
  • 984
  • 5
  • 16
0

You can use datetime module for the same result:

from datetime import datetime
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
sherdim
  • 1,159
  • 8
  • 19
nisakova
  • 89
  • 6