[Python] How to create a shortcut to run poetry anywhere?

Discussão em 'Python' iniciado por Stack, Agosto 18, 2025.

  1. Stack

    Stack Membro Participativo

    On an ubuntu environment I want to be able to use a shortcut to run poetry anywhere. Since I installed poetry in a folder /home/poetryfolder I create an alias as follows:

    alias prp='cd /home/poetryfolder && poetry run python'


    or

    alias prp='poetry --directory /home/poetryfolder run python'


    but when I try to run a python script inside the folder

    /home/scriptfolder


    with the command

    prp test.py


    then I get an error

    can't open file '/home/poetryfolder/test.py': [Errno 2] No such file or directory


    Of course, as the file test.py is in the folder /home/scriptfolder...

    How to solve this annoying issue with poetry without changing any folders or files?

    Continue reading...

Compartilhe esta Página