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
  is import cointegration_analysis a recognized module mitcht33 1 384 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  problem in import module from other folder akbarza 5 1,257 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 680 Aug-06-2023, 01:09 AM
Last Post: aupres
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,146 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  import module error tantony 5 3,358 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Import a module one step back of the path prathampatel9 1 1,035 Sep-21-2022, 01:34 PM
Last Post: snippsat
  Cryptic Error with import statement Led_Zeppelin 2 2,478 Jan-11-2022, 01:13 PM
Last Post: Led_Zeppelin
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,486 Jan-04-2022, 01:05 PM
Last Post: Anldra12
  Import a module for use in type hint? Milosz 0 1,455 Nov-08-2021, 06:49 PM
Last Post: Milosz
  Can't install nor import delorean module Tek 3 2,741 Oct-27-2021, 03:32 AM
Last Post: Tek

Forum Jump:

User Panel Messages

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