简体   繁体   English

Python 3.7.3 SystemError:错误返回,未设置异常

[英]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.

相关问题 Raspberry Pi2 Python adafruit_CharLCD SystemError:错误返回而未设置异常 - Raspberry pi2 Python adafruit_CharLCD SystemError: error return without exception set 创建numpy自定义对象数组会出现错误“SystemError:error return return without exception set” - Creating numpy array of custom objects gives error “SystemError: error return without exception set” 使用tf.data.Dataset.from_generator时出现“ SystemError:没有设置异常的错误返回” - “SystemError: error return without exception set” when using tf.data.Dataset.from_generator web.py有什么问题? SystemError:错误返回,没有设置异常 - what's wrong with web.py? SystemError: error return without exception set SystemError: 使用 ibm_db 连接到数据库时,无异常设置的错误返回 - SystemError: error return without exception set when connecting to the database using ibm_db Python-SystemError:NULL结果,PyObject调用中没有错误 - Python - SystemError: NULL result without error in PyObject call “系统错误:<class 'int'> 在 Python 中返回了带有错误集的结果”</class> - "SystemError: <class 'int'> returned a result with an error set" in Python SystemError:QtCore 初始化失败,没有引发异常 - SystemError: initialization of QtCore failed without raising an exception 错误返回,beaglebone上未设置任何异常 - error return without exception set on beaglebone 如何修复“系统错误:<built-in function 'name'> 在 Python C 扩展中返回 NULL 而不设置错误” - How to fix "SystemError: <built-in function 'name'> returned NULL without setting an error" in Python C Extension
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM