Python Forum
Trouble executing Python script
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble executing Python script
#1
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.
Reply
#2
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
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trouble with installing python domingo251 2 589 Sep-23-2023, 12:03 AM
Last Post: ICanIBB
  Syntax error while executing the Python code in Linux DivAsh 8 1,526 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,164 Jun-29-2023, 11:57 AM
Last Post: gologica
  Trouble with threading and reading variable from a different script Lembas 14 2,997 Apr-26-2023, 11:21 PM
Last Post: Lembas
Question How can I import a variable from another script without executing it ThomasFab 12 7,724 May-06-2022, 03:21 PM
Last Post: bowlofred
  Problem executing a script on a remote host tester_V 3 2,438 Sep-26-2021, 04:25 AM
Last Post: tester_V
  Facing error while executing below Python code ramu4651 1 5,707 Jan-26-2021, 06:40 PM
Last Post: ibreeden
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,863 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,283 May-28-2020, 05:27 PM
Last Post: micseydel
  New to python, having trouble with an exercise Salkay 3 2,134 Feb-18-2020, 01:42 AM
Last Post: Salkay

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020