[英]Python 3.7.3 SystemError: error return without exception set
I am trying to install libraries by Adafruit for MCP3008 AD converter.我正在尝试为 MCP3008 AD 转换器安装 Adafruit 库。 All installation process was successful, but after running a basic program, it shows me a error message.
所有安装过程都成功,但在运行基本程序后,它向我显示一条错误消息。 I am running this program on RPi4 with python 3.7.3.
我正在使用 python 3.7.3 在 RPi4 上运行这个程序。 Here is my code:
这是我的代码:
import time
import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008
SPI_PORT = 0
SPI_DEVICE = 0
mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
print('Reading MCP3008 values, press Ctrl-C to quit...')
print('| {0:>4} | {1:>4} | {2:>4} | {3:>4} | {4:>4} | {5:>4} | {6:>4} | {7:>4} |'.format(*range(8)))
print('-' * 57)
while True:
values = [0]*8
for i in range(8):
values[i] = mcp.read_adc(i)
print('| {0:>4} | {1:>4} | {2:>4} | {3:>4} | {4:>4} | {5:>4} | {6:>4} | {7:>4} |'.format(*values))
time.sleep(0.5)
And after calling specific program from my RPi4 using command:在使用命令从我的 RPi4 调用特定程序后:
sudo python3 adc.py
Console shows me this message:控制台向我显示此消息:
Traceback (most recent call last):
File "adc.py", line 7, in <module>
mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
File "/usr/local/lib/python3.7/dist-packages/Adafruit_GPIO-1.0.4-py3.7.egg/Adafruit_GPIO/SPI.py", line 46, in __init__
SystemError: error return without exception set
It is really annoying, because I can not figure out where the problem is.这真的很烦人,因为我无法弄清楚问题出在哪里。 I am pretty new in Python, but I read that it has something to do with C-2-Python interpreter.
我是 Python 的新手,但我读到它与 C-2-Python 解释器有关。 Can you please help me solve this problem?
你能帮我解决这个问题吗? It is for reading photodiode input using MCP3008 ADC.
它用于使用 MCP3008 ADC 读取光电二极管输入。 Thank you a lot!
十分感谢!
Solved.解决了。 The library I used is no longer supported for new RasPi OS, If you have the same problem, you have to use this command
sudo pip3 install adafruit-circuitpython-mcp3xxx
instead of git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
.新的 RasPi 操作系统不再支持我使用的库,如果你有同样的问题,你必须使用这个命令
sudo pip3 install adafruit-circuitpython-mcp3xxx
而不是git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
。 Of course, you have to make some other steps to reach full functionality of MCP3008.当然,您必须执行一些其他步骤才能实现 MCP3008 的全部功能。 For more info or steps do not hesitate to contact me.
如需更多信息或步骤,请随时与我联系。 I'll help if I'll know how.
如果我知道怎么做,我会帮忙的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.