[Hot News] [SOLVED]: AttributeError: 'module' object has no attribute 'setwarnings' in Raspberry Pi

[Hot News] [SOLVED]: AttributeError: 'module' object has no attribute 'setwarnings' in Raspberry Pi
Di Posting Oleh : Crew Blog
Kategori : FAQ PROGRAMMING Q&A RASPBERRY PI Solved TECHNOLOGY TUTORIALS


If you are new to Raspberry Pi and trying to run a sample Python script to turn on an LED connected to a GPIO module using GPIO Python library code, you may possibly encounter an error that reads something along these lines:

AttributeError: 'module' object has no attribute 'setwarnings'

If this is the case with your Raspberry Pi code, then chances are that you are trying to turn on the GPIO line using a very old version of Raspberry Pi GPIO Python library code.

To overcome this issue, all you have to do is uninstall any old version of the GPIO library on your Raspberry Pi to a latest version of the Raspberry Pi Python based GPIO library code.

To do that, simply perform the following instructions on your Raspberry Pi terminal:

$ sudo apt-get update
$ sudo apt-get remove python-rpi.gpio python3-rpi.gpio python-pip python3-pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
$ sudo python3 get-pip.py
$ sudo pip2 uninstall RPi.GPIO
$ sudo pip3 uninstall RPi.GPIO
$ sudo apt-get install python-rpi.gpio python3-rpi.gpio

Once you have successfully updated the Python based Raspberry Pi GPIO library, you should be able to turn on the GPIO pin, thereby turning ON the led which is attached to this respective GPIO line.

Hope this helps!