mkaz / termgraph

a python command-line tool which draws basic graphs in the terminal
MIT License
3.14k stars 165 forks source link

Cannot import API module #86

Closed yuvadm closed 3 years ago

yuvadm commented 3 years ago

The new API module as defined in #27 and #75 cannot be imported:

>>> from termgraph.module import Data, BarChart, Args, Colors
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/share/virtualenvs/foo-IGGZy7fP/lib/python3.9/site-packages/termgraph/module.py", line 12, in <module>
    from utils import cvt_to_readable
ModuleNotFoundError: No module named 'utils'
krazykoder commented 3 years ago

@mkaz seems like this package is compiled without a relative path to modules in the main package. Could we please help in fixing this. There are developers like us who prefer to import and use this in scripts and not just from command line. Appreciate the work you are doing and the open source contributions.

[Edit] - I think adding this in __init__.py should fix it.

import sys
from os.path import dirname
sys.path.append(dirname(__file__))
from termgraph import *
mkaz commented 3 years ago

Ok, I updated the __init__.py code with the import and deployed as v0.5.3

Can you confirm this fixes it for you? Thanks!

krazykoder commented 2 years ago

Yes this worked. Thanks for the fix and version update.