0

I'm having trouble calling Python code from a shell script on Ubuntu. First of all, I confirm that Python is installed:

username@Ubuntu22:~/Documents/Script$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/usr/local/lib/python3.10/dist-packages', '/usr/lib/python3/dist-packages']

I set the Python installation path by adding a line below to the .bashrc file:

export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.10

I'd like to run a simple shell script:

#!/bin/bash
python hello.py

by running ./ex_python_shell.sh but it gives me an error message:

./ex_python_shell.sh: line 2: python: command not found

Could you advise me what I'm doing wrong?

Ogiad
  • 21

0 Answers0