Python Forum
Trouble executing Python script - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Trouble executing Python script (/thread-4775.html)



Trouble executing Python script - NewburyPi - Sep-07-2017

I have installed a 2X16 LCD using the Adafruit instructions, and have successful run the script. However when I try to execute using command line (see below) I get the displayed message.

bob@Rover_II:~/Documents/SW_Dev/LCD_Buttons $ python3 AdminConsole_v2.py
Traceback (most recent call last):
File "AdminConsole_v2.py", line 6, in <module>
import Adafruit_CharLCD as LCD
ImportError: No module named 'Adafruit_CharLCD'

Note that by setting the .py file to executable

bob@Rover_II:~/Documents/SW_Dev/LCD_Buttons $ chmod a+x AdminConsole_v2.py

Allows me to run the script as below.

bob@Rover_II:~/Documents/SW_Dev/LCD_Buttons $ ./AdminConsole_v2.py

I assume that for some reason one method can find the library but the other cannot. Can you give me some insight on how to fix this?

Dale

PS: host is Raspberry Pi 3B; running Linux version 4.9.35-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #1014 SMP Fri Jun 30 14:47:43 BST 2017

Embarrassment here. I may have just stumbled across a solution to my problem. It seems that when I run the command

python AdminConsole_v2.py (that's python not python3)

all seems to work. Python3 seems to start the work but barfs on the library part. Not sure why, but feel I can move forward anyway.

PS: adafruit_support_carter has also identified the above, and suggests that I had only setup the library to work in Python2. I have confirmed this.


RE: Trouble executing Python script - Larz60+ - Sep-07-2017

Quote:but barfs on the library part?
How about some code with error messages(verbatim)
Also, which model LCD is it, adafruit has several 2 x 16 LCD's


RE: Trouble executing Python script - NewburyPi - Sep-07-2017

The problem has been resolved. it turns out to be an issue with how I installed the Adafruit library.

Quote:Embarrassment here. I may have just stumbled across a solution to my problem. It seems that when I run the command

python AdminConsole_v2.py (that's python not python3)

all seems to work. Python3 seems to start the work but barfs on the library part. Not sure why, but feel I can move forward anyway.

PS: adafruit_support_carter has also identified the above, and suggests that I had only setup the library to work in Python2. I have confirmed this.