how do I make a python program run from a bash shell?

on a raspberry pi I have a python script which runs without error from within Idle3 (sudo /usr/bin/idle3) When I try to run it from a shell script it fails with the error message "ImportError: No module named pytz".  It has no problem finding the other modules (picamera, time, and datetime)  I installed the pytz package using apt-get.
My searches have yielded suggestions relating to PATH, python installation etc. I cannot find documentation that has helped.
Doug BrennamanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

simon3270Commented:
Are you running it as
    python script.py
or
   python3 script.py

(in case pytz is only installed in Python3)
0
andreasSystem AdminCommented:
Im guessing you are using the wrong shebang.

type

which python3

Open in new window


e.g. the command yields /path/to/python3

and use its output as the shebang for the script and try again.

1st linx of the script should look like

#!/path/to/python3

Open in new window


then you should be able tu run it with ./scriptname.py
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Doug BrennamanAuthor Commented:
Andreas,
thank you.  That was the problem.  And thanks for providing the steps to correct it,
0
Doug BrennamanAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for Doug Brennaman's comment #a40460521

for the following reason:

The answer was educational.  I now know the reason for the error as well as the steps to solve it.
0
simon3270Commented:
Doug, I think you may have selected the wrong answer. Whether or not you give any points to me, you should at least give some to Andreas!
0
Doug BrennamanAuthor Commented:
Answer is informative, explained the problem and provided a fix.
0
Doug BrennamanAuthor Commented:
simon,
thanks for pointing that out.  I did make a mistake in accepting my own comment as the answer.  I have accepted Andreas's answer.  
This is the first time I've posted a question so I was unfamiliar with the process.
0
simon3270Commented:
No problem - we were all beginners once!

And welcome to EE.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.