繁体   English   中英

ImportError运行Test.py

[英]ImportError Running Test.py

我最近下载了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

因此,很明显,我在那里拥有所有东西,这不是特权问题。 不确定我应该怎么做。

对于冗长的帖子,我们深表歉意。

谢谢

您使用的Raspberry Pi是什么系统?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM