I have such a program to check methods of data from the command line:

me at me in ~/Desktop/Coding/codes
$ cat check_methods.py
#! /usr/bin/env python
from sys import argv
methods = dir(eval(argv[1]))
methods = [i for i in methods if not i.startswith('_')]

me at me in ~/Desktop/Coding/codes
$ python check_methods.py list
['append', 'clear', 'copy', 'count', 'extend', 'index',
    'insert', 'pop', 'remove', 'reverse', 'sort']

me at me in ~/Desktop/Coding/codes
$ python check_methods.py dict
['clear', 'copy', 'fromkeys', 'get', 'items', 'keys',
    'pop', 'popitem', 'setdefault', 'update', 'values']

I'd like to run the program directly from bash, like:

$ check_methods.py list
-bash: check_methods.py: command not found

How to achieve it ?

1 Answer 1


Specify the path to the script, since it isn't in $PATH.

./check_methods.py list

And never add . to $PATH.

  • 1
    They could add $HOME/Desktop/Coding/codes to the end of $PATH if they wanted. Or move the script to $HOME/local/bin or some such location and add that to the end of $PATH.
    – Kusalananda
    May 10, 2018 at 7:04
  • $ ./check_methods.py dict -bash: ./check_methods.py: Permission denied $ sudo ./check_methods.py dict sudo: ./check_methods.py: command not found Must it transmit to $PATH before it works?
    – Wizard
    May 10, 2018 at 7:08
  • 2
    No, but you need to make it executable, just like every other executable in existence. May 10, 2018 at 7:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .