bash: python: .py: command not found

bash: python: .py: command not found

To execute a Python script in this way, you need three things:

  1. The file needs to have the executable bit set for you. To do this, try using: chmod u+x validate_mapping_file.py

  2. The file needs to begin with a shebang, for example #!/usr/bin/env python3 which will tell the system to run the script using the python3 executable according to your environment

  3. The file needs to be in one of the directories in your PATH environment variable. You can add the current directory using export PATH=$PWD:$PATH or use ./validate_mapping_file.py instead of just validate_mapping_file.py (thanks @Grisha)

Afterwards you should be able to execute the script the way you tried before.

bash: python: .py: command not found

Leave a Reply

Your email address will not be published. Required fields are marked *