We help IT Professionals succeed at work.

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

529 Views
Last Modified: 2016-08-13
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.
Comment
Watch Question

CERTIFIED EXPERT

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

(in case pytz is only installed in Python3)
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Andreas,
thank you.  That was the problem.  And thanks for providing the steps to correct it,

Author

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.
CERTIFIED EXPERT

Commented:
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!

Author

Commented:
Answer is informative, explained the problem and provided a fix.

Author

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.
CERTIFIED EXPERT

Commented:
No problem - we were all beginners once!

And welcome to EE.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.