简体   繁体   English

ImportError运行Test.py

[英]ImportError Running Test.py

I recently downloaded ACRCloud and began trying to use it to recognize music on the Raspberry Pi. 我最近下载了ACRCloud,并开始尝试使用它来识别Raspberry Pi上的音乐。 So, the first thing I did was run the setup.py script with the following command: 因此,我所做的第一件事是使用以下命令运行setup.py脚本:

sudo python setup.py install

Everything runs fine and all the necessary files are created. 一切正常,并创建了所有必要的文件。 Next thing I did was enter my API information into the test.py file. 我要做的下一件事是将我的API信息输入到test.py文件中。 It currently looks like this with the information entered: 输入的信息当前看起来像这样:

#!/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

Nothing other than the host, access key, or access secret have been touched, and I removed them here. 除了主机,访问密钥或访问机密之外,没有其他任何更改,我在这里将其删除。 Next, I try running the following command: 接下来,我尝试运行以下命令:

sudo python test.py test.mp3

This should return the song, as my directory contains both files. 这应该返回歌曲,因为我的目录包含两个文件。 ls -la returns the following: 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

However, when I run the command above, I get the following error: 但是,当我运行上面的命令时,出现以下错误:

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

I have checked to ensure that the shared object file is where it says it is. 我已经检查以确保共享库文件位于它所说的位置。 Doing ls -la in the python2.7/acrcloud directory gives me the following: 在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

So it's pretty clear that I have everything there, and it's not a privilege issue. 因此,很明显,我在那里拥有所有东西,这不是特权问题。 Not entirely sure what I should do. 不确定我应该怎么做。

Apologies for the lengthy post, just wanted to be completely thorough. 对于冗长的帖子,我们深表歉意。

Thanks 谢谢

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

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

相关问题 ImportError:在使用virtualenv的PyCharm下没有名为test_data的模块,但是test_data.py与test.py在同一目录中 - ImportError: No module named test_data, but test_data.py in same directory as test.py under PyCharm using virtualenv 通过 python Pytest 从一个 test.py 文件运行多个测试文件 - Running multiple test files from one test.py file through python Pytest 自动完成test.py像git <tab> - autocomplete for test.py like git <tab> test.py:第3行:导入:找不到命令test.py:第5行:标头:找不到命令 - test.py: line 3: import: command not found test.py: line 5: headers: command not found Django test.py model object 实例仅限一次测试 - Django test.py model object instance is limited to one test &#39;%%file test.py&#39; 在 python 中是什么意思? - what does '%%file test.py' mean in python? 如何在“vim test.py”中编写这种类型的代码 - How to write this type of code in “vim test.py” 使用scrapy将变量传递到Spider文件夹中的test.py - Pass variable to test.py in spider folder using scrapy ArgParse错误。 但在Test.py文件中工作 - ArgParse ERROR. but working in Test.py file ImportError显示py.test,但在运行应用程序时不显示 - ImportError shows up with py.test, but not when running the app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM