ImportError运行Test.py

时间:2018-03-09 15:44:03

标签: python raspberry-pi acrcloud

我最近下载了ACRCloud并开始尝试用它来识别Raspberry Pi上的音乐。所以,我做的第一件事就是使用以下命令运行setup.py脚本:

sudo python setup.py install

一切运行正常,并创建了所有必需的文件。我接下来要做的是将我的API信息输入test.py文件。目前看来输入的信息如下:

#!/usr/bin/env python
#-*- coding:utf-8 -*-

'''
    >>> python test.py test.mp3
'''

import os, sys
from acrcloud.recognizer import ACRCloudRecognizer
from acrcloud.recognizer import ACRCloudRecognizeType

if __name__ == '__main__':
    config = {
        'host':'--------------',
        'access_key':'--------------',
        'access_secret':'--------------',
        'recognize_type': ACRCloudRecognizeType.ACR_OPT_REC_AUDIO, # you can replace it with [ACR_OPT_REC_AUDIO,ACR_OPT_REC_HUMMING,ACR_OPT_REC_BOTH], The SDK decide which type fingerprint to create accordings to "recognize_type".
        'debug':False,
        'timeout':10 # seconds
    }

    '''This module can recognize ACRCloud by most of audio/video file. 
        Audio: mp3, wav, m4a, flac, aac, amr, ape, ogg ...
        Video: mp4, mkv, wmv, flv, ts, avi ...'''
    re = ACRCloudRecognizer(config)

    #recognize by file path, and skip 0 seconds from from the beginning of sys.argv[1].
    print re.recognize_by_file(sys.argv[1], 0, 10)

    buf = open(sys.argv[1], 'rb').read()
    #recognize by file_audio_buffer that read from file path, and skip 0 seconds from from the beginning of sys.argv[1].
    print re.recognize_by_filebuffer(buf, 0, 10

触摸了主机,访问密钥或访问密钥以外的任何内容,我在此处将其删除。接下来,我尝试运行以下命令:

sudo python test.py test.mp3

这应该返回歌曲,因为我的目录包含两个文件。 ls -la返回以下内容:

drwxrwxrwx 6 pi   pi       4096 Mar  9 15:26 .
drwxr-xr-x 3 pi   pi       4096 Feb 15 08:36 ..
drwxrwxrwx 2 pi   pi       4096 Mar  9 01:08 acrcloud
drwxr-xr-x 4 root root     4096 Mar  9 00:46 build
drwxr-xr-x 2 root root     4096 Mar  9 00:46 dist
drwxr-xr-x 2 root root     4096 Mar  9 00:46 pyacrcloud.egg-info
-rw-r--r-- 1 pi   pi        570 Feb 15 08:36 setup.py
-rw-r--r-- 1 pi   pi   10724969 Mar  9 01:07 test.mp3
-rw-r--r-- 1 pi   pi       1291 Mar  9 01:05 test.py
-rw-r--r-- 1 pi   pi      12288 Mar  9 00:54 .test.py.swp

但是,当我运行上面的命令时,我收到以下错误:

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    from acrcloud.recognizer import ACRCloudRecognizer
  File "/home/pi/Downloads/ACRCloud/raspberrypi/python2.7/acrcloud/recognizer.py", line 21, in <module>
    import acrcloud_extr_tool
ImportError: /home/pi/Downloads/ACRCloud/raspberrypi/python2.7/acrcloud/acrcloud_extr_tool.so: cannot open shared object file: No such file or directory

我已经检查过以确保共享对象文件在它所说的位置。在python2.7 / acrcloud目录中执行ls -la可以得到以下结果:

drwxrwxrwx 2 pi   pi       4096 Mar  9 01:08 .
drwxrwxrwx 6 pi   pi       4096 Mar  9 15:26 ..
-rwxr-xr-x 1 pi   pi   11270324 Feb 15 08:36 acrcloud_extr_tool.so
-rw-r--r-- 1 pi   pi        182 Feb 15 08:36 __init__.py
-rw-r--r-- 1 root root      157 Mar  9 01:08 __init__.pyc
-rwxr-xr-x 1 pi   pi      10990 Feb 15 08:36 recognizer.py
-rw-r--r-- 1 root root     8693 Mar  9 01:08 recognizer.pyc

所以我很清楚我拥有一切,而且这不是特权问题。不完全确定我应该做什么。

对于冗长的帖子抱歉,只是想彻底彻底。

由于

1 个答案:

答案 0 :(得分:0)

你正在使用的Raspberry Pi系统是什么?