Python Forum
Error while humansize module import.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error while humansize module import.
#1
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.
Reply
#2
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.
- Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. Albert Einstein
Reply
#3
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'
Reply
#4
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')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  import module with syntax error Skaperen 7 369 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  Import Error Christian 3 669 Apr-17-2021, 11:27 PM
Last Post: bowlofred
  'urllib3' Module not found when import 'requests' spanz 5 1,504 Jan-06-2021, 05:57 PM
Last Post: snippsat
  Folium import error kashif_flavio 2 678 Dec-07-2020, 08:58 AM
Last Post: bowlofred
  Import error Beingcode 0 776 Nov-20-2020, 02:57 AM
Last Post: Beingcode
Smile Import error with local file colt 1 540 Nov-08-2020, 07:56 AM
Last Post: Gribouillis
  switch from version 3.5.3 to 3.8.6 get import error python001 9 943 Oct-31-2020, 03:02 PM
Last Post: python001
  Problem with Flask Bcrypt import module marcello86 2 1,061 Aug-31-2020, 08:10 PM
Last Post: marcello86
  import yaml error for python3 maiya 4 3,582 Jul-15-2020, 06:07 PM
Last Post: Gribouillis
  Unable to import my own module ThePhantom 3 885 May-01-2020, 01:30 AM
Last Post: menator01

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020