1

I defined some command line tools of python (take mycmd.py as an example), and saved them in the folder ~/Scripts. Hence, I have to type (for example) python /Scripts/mycmd.py -o v. It is tedious to repeat the name of the folder /Scripts. I want to run the command only inputting python mycmd.py -o v, even without cd. How should I do? Add a path to the original one?

PS: in mac

William Song
  • 577
  • 6
  • 17

2 Answers2

1

Maybe there's a better solution:

Then you can call your scripts like any other tool (without python prefix), ex:

mycmd.py -o v

On Windows, you don't even need a shebang, since .py files are seen as launchable files, associated with the installed python interpreter. Putting the dir in the path is enough.

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
-1

Add the path to PYTHONPATH environment variable.

Abhishake Gupta
  • 2,939
  • 1
  • 25
  • 34