In the following piece of code I make a connection to my raspberry from pycharm. ledon makes the connection correctly and allows me to turn the led on/off by running the program from windows.
from tkinter import *
from tkinter import ttk
from gpiozero import LED, Motor
from gpiozero.pins.pigpio import PiGPIOFactory
factory = PiGPIOFactory(host='192.168.31.150')
ledon = LED(17, pin_factory=factory)
ledon.on()
motor1 = Motor(23, 24, pwm=True, pin_factory=factory)
motor1.forward()
In the case of motor1 it gives the following error I don't quite understand what is missing, I have tried to install the RPi.GPIO package in pycharm but it gives an error there is no way
C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi'
warnings.warn(
C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio'
warnings.warn(
C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from rpio: No module named 'RPIO'
warnings.warn(
C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from pigpio: failed to connect to localhost:8888
warnings.warn(
C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from native: [Errno 2] No such file or directory: '/proc/cpuinfo'
warnings.warn(
Traceback (most recent call last):
File "P:\PROYECTOS\RCC\main.py", line 29, in <module>
motor1 = Motor(23, 24, pwm=True, pin_factory=factory)
File "C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py", line 108, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\output_devices.py", line 1223, in __init__
super(Motor, self).__init__(_order=devices.keys(), **devices)
File "C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\mixins.py", line 85, in __init__
super(SourceMixin, self).__init__(*args, **kwargs)
File "C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py", line 432, in __init__
super(CompositeDevice, self).__init__(pin_factory=pin_factory)
File "C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py", line 250, in __init__
Device.pin_factory = Device._default_pin_factory()
File "C:\Users\calde\AppData\Local\Programs\Python\Python39\lib\site-packages\gpiozero\devices.py", line 291, in _default_pin_factory
raise BadPinFactory('Unable to load any default pin factory!')
gpiozero.exc.BadPinFactory: Unable to load any default pin factory!