After I install pca9685() according to the online method, the following errors will appear in the operation.
>>> pwm = Adafruit_PCA9685.PCA9685() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'Adafruit_PCA9685' is not defined >>> import Adafruit_PCA9685 >>> pwm = Adafruit_PCA9685.PCA9685() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.7/dist-packages/Adafruit_PCA9685-1.0.1-py3.7.egg/Adafruit_PCA9685/PCA9685.py", line 75, in __init__ self.set_all_pwm(0, 0) File "/usr/local/lib/python3.7/dist-packages/Adafruit_PCA9685-1.0.1-py3.7.egg/Adafruit_PCA9685/PCA9685.py", line 111, in set_all_pwm self._device.write8(ALL_LED_ON_L, on & 0xFF) File "/usr/local/lib/python3.7/dist-packages/Adafruit_GPIO-1.0.4-py3.7.egg/Adafruit_GPIO/I2C.py", line 116, in write8 self._bus.write_byte_data(self._address, register, value) File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO-1.1.9-py3.7.egg/Adafruit_PureIO/smbus.py", line 327, in write_byte_data OSError: [Errno 121] Remote I/O error
But the premise of this method is to have the Adafruit_PCA9685 file under the path /usr/local/lib/python3.7/dist-packages/”, if there is one, use the above method
My Raspberry Pi is 4B, there are three .egg files in the above path, Adafruit_PCA9685 is placed in it, as shown below
Select the middle of the Adafruit_PCA9685 .egg file, there will be PCA9685.py file, just create PCA9685.py under raspberry home/pi/ and paste the contents of the previous PCA9685.py into the newly created file, import the code to import PCA9685 instead of not import Adafruit_PCA9685
Open the PCA9685 file and find that it needs to import the I2C.py file (I forgot to take a screenshot), then open the first one under the /usr/local/lib/python3.7/dist-packages/ path
Paste the contents of I2C.py and Plaform.py inside this file into a new I2C.py and Plaform.py file under home/pi, then open the PCA9685.py file in this directory and change the imported I2C in the middle position, it seems to be form Adafurit_GPIO import I2C as I2C directly to import I2C.
Then open the I2C file, found that you need to import Plaform.py, the same operation, change the previous import to import Plaform can be, as shown, and finally in the directory I2C.py PCA9685.py and Plaform.py file
You can write it directly in the raspberry pie file
import PCA9685 pwm = PCA9685.PCA9685()
See if it’s successful. I’m successful.
- Raspberry pie compilation and installation opencv error: fatal error: bootdesc_bgm.i: No such file or directory
- Python raspberry pie starts sending IP address to mailbox
- Raspberry pie import opencv error: ImportError: numpy.core.multiarray failed to import
- Python IndexError: too many indices for array: array is 1-dimensional, but 2 were i..
- [Solved] Pygame Install Error: Command errored out with exit status 255: hg clone –noupdate -q https://bitbucket.o
- Python Use sqlalchemy Error: pymssql.ProgrammingError: (102, b“Incorrect syntax near ‘(‘.DB-Lib error
- [Solved] ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
- Python: SVN deletes files on local and remote repositories
- ValueError: Found array with dim 4. Estimator expected and ValueError: Expected 2D array, got 1D array i
- RuntimeError: Address already in use [How to Solve]
- [Solved] Converting IU to py using pyuic5 – O reports an error importerror: DLL load failed while importing qtcore: the specified module cannot be found.
- [Solved] Run sudo python setup.py install Error: error: error in setup.cfg: command ‘build‘ has no such option ‘i18
- [Solved] python opencv Error: findContours() Can only use the Grayscale
- [Solved] error in REfO setup command: use_2to3 is invalid.
- [Solved] Pycharm Use pip to install package error: no such option –build-dir
- Python: How to Use os.path.join()
- Python Use PIP to install pyinstaller Error [Solved]
- [Solved] Jupyter notebook use pyLDAvis Error: modulenotfounderror: no module named ‘pyLDAvis’‘
- [Solved] Windows10 Pycharm Use Virtual Environment Error: Cannot set up a python SDK
- Ab3dmot vehicle pedestrian recognition (How to Use)