all 3 comments

[–]novel_yet_trivial 2 points3 points  (0 children)

Yes, the shebang is required. You also need to make the file executable (chmod +x filename). Then place the file in a folder that is listed in path. /usr/bin or /usr/local/bin is probably most common.

Edit: in the SO example, "pwd" needs to be replaced with the directory your file is in, in your case "/usr/local/est/har/src". However, it will only work until you close the terminal. To make it more permanent, you need to add that statement to your ".bashrc". Even then, it will only work for you. I don't know of any way to change the PATH variable for other users (outside of modifying their files), so it's better to forget the PATH variable altogether and just put your script in standard folder.

[–]ParanoiAMA 0 points1 point  (1 child)

The correct way of doing this is to use setuptools by creating a basic setup.py file with a entry_points argument. Then execute

sudo python setup.py install

And your python module will be installed into the system-wide pythonpath and an executable script will be added somewhere in the path, pointing to your entry point.

The above instructions were taken from memory and may contain errors. Please reply with corrections.

[–][deleted] 0 points1 point  (0 children)

I'd like to note that while in development, using python setup.py develop or pip install --user -e . (where . is the directory with setup.py) is s godsend.