sqlite ImportError:没有名为libs的模块

eqfvzcg8  于 2023-05-23  发布在  SQLite
关注(0)|答案(2)|浏览(168)

我试图在终端中运行名为www.example.com的代码recognize-from-microphone.py。代码是广泛的,所以我不会键入整个事情了。代码的目标是识别来自连接到我的Raspberry Pi的USB麦克风的音频。
下面是你需要知道的部分代码:

import os
import sys
import libs
import fingerprint as fingerprint
import argparse

from argparse import RawTextHelpFormatter
from itertools import zip_longest
from termcolor import colored
from config import get_config
from reader_microphone import MicrophoneReader
from visualiser_console import VisualiserConsole as visual_peak
from visualiser_plot import VisualiserPlot as visual_plot
from db_sqlite import SqliteDatabase
from db_mongo import MongoDatabase

if __name__ == '__main__':
  config = get_config()

  db = SqliteDatabase()

  parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter)
  parser.add_argument('-s', '--seconds', nargs='?')
  args=parser.parse_args()

if not args.seconds:
  parser.print_help()
  sys.exit(0)

代码需要一个插入到终端中的参数。我在终端输入这个:

pi@raspberrypi:~/Desktop/Research/audio_recognition_system $ python recognize-from-microphone.py -s 5

-s 5是所需秒数的参数。但是,它返回以下错误:

Traceback (most recent call last):
File "recognize-from-microphone.py", line 4, in <module>
   import libs
ImportError: No module named libs

然而,当我把

pip install libs

它返回:

Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: libs in /home/pi/.local/lib/python3.7/site-packages (0.0.9)

当我试图在编译器中运行它时,它只是退出系统,因为参数没有插入,我不知道在实际代码中在哪里或如何插入参数,我只知道在终端中的哪里放置参数。如果有人能帮上忙,那就太好了,谢谢。
旁注:目录中还有一个名为libs的空文件夹,这可能是问题的一部分吗?

6bc51xsx

6bc51xsx1#

这个错误并不是因为那个文件夹,而是可能因为模块安装在错误的版本中。
通常执行pip install libs命令。好吧,让我们改变它,你会明白它在短短的一秒钟。

**我的修复:**尝试使用以下方法:

py -m pip install libs

使用此命令将让我们在当前活动的特定Python版本中安装模块,该版本为"right"版本。

  • 我以前有这个问题,因为我有3个不同版本的Python安装在我的PC上。这是我的解决方案,我可以说这对我有效。*

谢谢你!

wtlkbnrh

wtlkbnrh2#

在Mac上:
打开终端,

Tensorflow/labelimg admin$pyrcc5 -o libs/resources.py resources.qrc

相关问题