simplest.some_function() AttributeError: module 'simplest' has no attribute 'some_function'
时间: 2023-06-21 08:08:04 浏览: 50
这个错误通常是因为你导入了一个模块,但该模块并没有包含你要使用的函数或属性。你需要检查一下导入的模块中是否真的包含了你需要的函数或属性。
另外,如果你修改了模块代码,记得重新加载模块。你可以使用 `importlib.reload()` 函数重新加载模块,例如:
```python
import importlib
import simplest
# 修改了 simplest 模块的代码
importlib.reload(simplest)
```
这样就可以确保你使用的是最新的代码。
相关问题
while True: proc = subprocess.Popen(["python3", "/home/pi/Documents/8-17/simplest.py"]) while proc.poll() is None: time.sleep(1) print("simplest运行中.....") chinanet = isNetChainOK() if chinanet is False: print("网络异常") for proc in psutil.process_iter(): if proc.name() == 'simplest.py': print("simplest受网络问题强行中断") proc.terminate() # or proc.kill() proc = subprocess.Popen(["python3", "/home/pi/Documents/8-17/simplest.py"]) getNet() 断网后报错:while proc.poll() is None: AttributeError: 'Process' object has no attribute 'poll'
这个错误可能是因为 subprocess.Popen() 方法返回的对象类型不是 Process 类型,而是 NoneType 类型。这可能是由于 subprocess.Popen() 调用失败导致的。
你可以在调用 subprocess.Popen() 方法之前添加一些错误处理代码,以避免此错误。例如:
```
while True:
try:
proc = subprocess.Popen(["python3", "/home/pi/Documents/8-17/simplest.py"])
break
except Exception as e:
print("Error starting process:", e)
time.sleep(1)
while proc.poll() is None:
time.sleep(1)
print("simplest运行中.....")
chinanet = isNetChainOK()
if chinanet is False:
print("网络异常")
for proc in psutil.process_iter():
if proc.name() == 'simplest.py':
print("simplest受网络问题强行中断")
proc.terminate() # or proc.kill()
proc = subprocess.Popen(["python3", "/home/pi/Documents/8-17/simplest.py"])
getNet()
```
这样,如果 subprocess.Popen() 调用失败,代码将等待 1 秒钟,然后重试。如果调用成功,代码将继续执行。
simplest_ffmpeg_player.c:34:5: error: implicit declaration of function 'av_find_stream_info' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if(av_find_stream_info(pFormatCtx)<0)
这个错误的意思是在C99标准下隐式声明函数'av_find_stream_info'无效,并且在编译期间出现了这个错误。要解决这个问题,你可以在你的代码中添加一个头文件“libavformat/avformat.h”,因为这个头文件包含了'av_find_stream_info'函数的声明。在头部添加这个文件后,重新编译你的代码,这个错误就会被修复。