typer-cli icon indicating copy to clipboard operation
typer-cli copied to clipboard

Typer command can not run a script which imports other original scripts.

Open NMZ0429 opened this issue 2 years ago • 2 comments

First and foremost, thank you so munch for developing this awesome library and I hope I don't bother you by opening this issue.

The problem is that I can not use typer-cli command to run a function if it's importing other python scripts.

Given the file structure and contents, the command typer main.py run fails.

.
├── main.py
├── helloworld.py

main.py

import typer
from helloworld import print_hello


def greet():
    print_hello()


if __name__ == "__main__":
    typer.run(greet)

helloworld.py

def print_hello():
    print("Hello World")

output

$typer main.py run
...
ModuleNotFoundError: No module named 'helloworld'

NMZ0429 avatar Aug 13 '22 15:08 NMZ0429

I'm also having this issue. Did you end up finding a solution for it @NMZ0429 ?

vinigfer avatar May 23 '23 03:05 vinigfer

yohay13 avatar Aug 11 '23 12:08 yohay13