Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Pi TFT and Python 3
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Pi TFT and Python 3

by tarnis on Sat Aug 01, 2020 5:59 pm

I see most of the examples used 2.7, and some code I've written does work in 2.7 but I started out trying to write a script in 3.0 to control the buttons on the screen as well as some extra buttons I'm wiring into the GPIO pins through a ribbon cable connected to the output that's soldered onto the board. Python gives errors and seems to think that I do not have a raspberry pi if I do any of that in 3.0 though.

Is there a workaround? 2.7 is a little old at this point and going away fairly soon.

tarnis
 
Posts: 17
Joined: Thu Feb 16, 2017 12:36 pm

Re: Pi TFT and Python 3

by tarnis on Sat Aug 01, 2020 7:48 pm

Python 2
Code: Select all | TOGGLE FULL SIZE
pi@PiCam:~/scripts $ sudo python2
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> quit()


Python 3
Code: Select all | TOGGLE FULL SIZE
pi@PiCam:~/scripts $ sudo python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: This module can only be run on a Raspberry Pi!
>>>

tarnis
 
Posts: 17
Joined: Thu Feb 16, 2017 12:36 pm

Re: Pi TFT and Python 3

by adafruit_support_carter on Mon Aug 03, 2020 12:30 pm

What TFT and guide are you working with? In general, anything new will be Python 3. Anything you might come across that is Python 2 is outdated and we should update it.

adafruit_support_carter
 
Posts: 16944
Joined: Tue Nov 29, 2016 2:45 pm

Re: Pi TFT and Python 3

by tarnis on Mon Aug 03, 2020 12:56 pm

It's the PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen

I used these directions a few months back when I bought it, finally finding some time to begin writing some code and finding nothing works in python 3.

https://learn.adafruit.com/adafruit-pit ... spberry-pi

Regards,
Matt

tarnis
 
Posts: 17
Joined: Thu Feb 16, 2017 12:36 pm

Re: Pi TFT and Python 3

by tarnis on Mon Aug 03, 2020 9:33 pm

I think I have things sorted out, but I'm not sure where things went off the rails...I assumed the installer script maybe installed an old copy of RPi.GPIO but I don't see it in there...nor OpenCV which is the only other thing I installed and yet it's here. I deleted the directory from python and I think that cleared things up so its using the default raspian install now.

tarnis
 
Posts: 17
Joined: Thu Feb 16, 2017 12:36 pm

Please be positive and constructive with your questions and comments.