Making Python script accessible to the whole system

Can someone tell me how to make my script available in any directory?

My script just returns the number of files in the directory. I would like it to work in any directory, calling it, instead of copying there first and then typingpython myscript.py

I am using Mac OS X, but is there a general way to install it on Windows and Linux?

+3
source share
2 answers

If your script starts with a suitable shebang line, for example:

#!/usr/bin/env python

And your script has a set of executable bits (for Linux, OS X and other Unix-like systems):

chmod +x myscript.py

And the path to your script is in the PATH environment variable:

export PATH=${PATH}:`pwd` # on Unix-like systems

SET PATH=%PATH%;\path\to # on Windows

myscript.py, .

+12

PATH, , , . script chmod +x ( PATH - , ~/bin).

, , Windows, , , .bat .

0

Source: https://habr.com/ru/post/1765451/


All Articles