Python Forum

Full Version: Error while humansize module import.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Error message while trying to import humansize. Please help
from humansize import approximate_size
The error message is:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from humansize import approximate_size
ModuleNotFoundError: No module named 'humansize'

(I am having humansize ver. 1.0 in pip list.)
Please help me.
I tried it too but for some reason I cannot find any code intalled after the installation, but indeed humansize is in pip list... i can only find the zipfile with some metadata and stuff. On PyPi there is no documentation at all. But I searched on GitHub and got some alternatives you may want to look into.
The file is not in PyPi repo only setup.py.
The file is still on the web.
Just save save as humansize.py and use it as module.
>>> from humansize import approximate_size
>>> 
>>> approximate_size(1024)
'1.0 KiB'
>>> approximate_size(4096)
'4.0 KiB'
>>> approximate_size(100000)
'97.7 KiB'
>>> approximate_size(10000000000000)
'95.4 MiB'
>>> approximate_size(10000000000000)
'9.1 TiB'
Thank you, it worked. Even though I had to add a new path to make it global.
import sys
sys.path.append(r'C:\Users\JOHNSON K G\AppData\Local\Programs\Python\Python38\Lib\site-packages\humansize-1.0-py3.8.egg-info')