Python Forum
Python IDLE 3.6.2 on WIn7 vs Pyhton 3 IDLE raspberry
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python IDLE 3.6.2 on WIn7 vs Pyhton 3 IDLE raspberry
#1
Hi! all.
First question:
I have a small starter program that bugs me. I took this one on the net
and work well in Raspberry Pi3 Stretch & Python 2.7.13, in command line
like: python test01.py , it print too, the version of running GPIO = 0.6.3
But when I try it with Python 3.6.2 in Raspberry or on the Python 3.6.2 on Windows 7
it give me this on both:
Traceback (most recent call last):
File "test01.py", line 1, in <module>
import RPi.GPIO as GPIO
ModuleNotFoundError: No module named 'RPi'

What can I do to be able to make it work.

Second question:
I build the Python 3.6.2 on rapsberry pi3 "Raspbian GNU/Linux 9 (stretch)"
using this internet address as a guide:
"bohdan-danishevsky.blogspot.ca/2017/01/building-python-360-on-raspberry-pi-3.html"
Everything works well when I type python3.6 , But If I type python, then it's 2.7.13.

What ca I do to have version 3.6.2 when I type python.

Thanks Smile
--------------------------------------------------

import RPi.GPIO as GPIO
import time

LedPin = 11 # pin11

def setup():
GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location
GPIO.setup(LedPin, GPIO.OUT) # Set LedPin's mode is output
GPIO.output(LedPin, GPIO.HIGH) # Set LedPin high(+3.3V) to turn on led

def blink():
while True:
GPIO.output(LedPin, GPIO.HIGH) # led on
time.sleep(1)
GPIO.output(LedPin, GPIO.LOW) # led off
time.sleep(1)

def destroy():
GPIO.output(LedPin, GPIO.LOW) # led off
GPIO.cleanup() # Release resource

if __name__ == '__main__': # Program start from here
setup()
try:
blink()
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed.

destroy()
Reply
#2
you will need to install the python 3 RPi.GPIO package.
do you have pip on the pi?
if so, the command will be:
pip3 install RPi.GPIO 
Reply
#3
To answer your second question python2.7 is installed on the raspberry pi by default.
Typing:

which python

which python3

will return the relative path. You can create a symlink but this is not advisable
as any other software that requires python2.7 will break.

You should be able to run python 3.6 just by typing
python3

On debian 8 this defaults to python3.4.3, I've not upgraded to DEbian 9 yet.
Reply
#4
Quote:Everything works well when I type python3.6 , But If I type python, then it's 2.7.13
 the paths are messed up. Don't know how to fix this in firmware.
you may have to specifically use python
python3.6 myscript.py
Reply
#5
Hey! thanks
I thought that since it appears to be 0.6.3 on the default Python 2.7.13,
it was the same module used bu the Python 3.6.2. My mistake.
I used "sudo pip3 install RPi.GPIO" and everything works properly.
Reply
#6
Good!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why can I not see the code correctly in Python IDLE.? Trump 7 438 Mar-14-2024, 09:05 PM
Last Post: deanhystad
  problem with help(type(self)) in Idle akbarza 1 432 Dec-26-2023, 12:31 PM
Last Post: Gribouillis
  save a session in idle akbarza 5 697 Nov-06-2023, 08:36 AM
Last Post: snippsat
  Vlookup function in Pyhton antozas 1 590 Oct-02-2023, 04:16 AM
Last Post: vikraman
  [PROBLEM] Removing IDLE from context menu WebSpider 1 426 Sep-28-2023, 03:35 PM
Last Post: deanhystad
  Recommendations for IMAP Push/IDLE library MikeFlorida 0 774 Jul-15-2023, 05:19 PM
Last Post: MikeFlorida
  What is all the info in the info window in Idle? Pedroski55 3 647 Jul-08-2023, 11:26 AM
Last Post: DeaD_EyE
  create a default path with idle to a specific directory greybill 0 846 Apr-23-2023, 04:32 AM
Last Post: greybill
  Video recording with Raspberry Pi - What´s wrong with my python code? Montezuma1502 3 1,180 Feb-24-2023, 06:14 PM
Last Post: deanhystad
  Launch Python IDLE Shell from terminal Pavel_47 5 1,143 Feb-17-2023, 02:53 PM
Last Post: Pavel_47

Forum Jump:

User Panel Messages

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