Python console_scripts doesn't work when pip i

2020-05-02 18:04发布

问题:

I wrapped my code into python package and now I want it to be also runnable from the command line (linux). So I added console_scripts tag to setup.py and all seems to be working fine when I pip install it as a root. (I can run program from the command line)

However I'd also like for a package to be installed by using

pip install --user .

so it can be installed on computers when root is not available to the user. However when I try to invoke program from the command line i got 'command not found'. The pip installation finishes successfully and I can still run it using

python my_prog.py

But I wonder is there any solution to this problem. Can someone please explain how the console_scripts setup.py tag actually works?

Any ideas welcome.

回答1:

pip installs the scripts under ~/.local/bin. You need to add this to your PATH with:

export PATH=~/.local/bin:$PATH


标签: python pip pypi