1

I am trying to run this code named recognize-from-microphone.py in the terminal. The code is extensive so I will not type the whole thing out. The goal of the code is to recognize audio from the usb microphone attached to my Raspberry Pi.

Here's the part of the code that you need to know:

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)

The code needs a parameter that is inserted in the terminal. I type this in the terminal:

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

The -s 5 is the parameter for seconds needed. However, it returns this error:

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

However, when I put

pip install libs

it returns:

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)

When I try to run it in the compiler, it just exits the system because the parameter isn't inserted and I don't know where or how to insert the parameter in the actual code, I just know where to put the parameter in the terminal. If anyone could help that would be great, thank you.

Side note: there's also an empty folder named libs inside of the directory, could this be part of the problem?

2 Answers2

0

This error is not really because of that folder but maybe because module is being installed in the wrong version.

You usually do the command pip install libs. Well, let's change it and you would understand it in just a second.

My Fix: Try using the following:

py -m pip install libs

Using this command will let us install the module in the specific version of Python which is currently active and which is "right" one for you.

I used to have this problem earlier as I had 3 different versions of Python installed on my PC. Well this was the fix for me and I can say that this works for me.

Thank You!

Bhavyadeep Yadav
  • 819
  • 8
  • 25
0

on Mac:

open terminal,

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

gshoanganh
  • 137
  • 1
  • 3