You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派使用ACRCloud识别音乐时运行test.py遭遇ImportError

Fixing ACRCloud ImportError on Raspberry Pi

Alright, let's tackle that ImportError you're hitting when running test.py after setting up ACRCloud on your Pi. Here are the most common fixes, based on issues I've seen with ARM-based systems like Raspberry Pi:

1. Double-Check Your Python Environment

Raspberry Pi often has both Python 2 and 3 installed, and it's easy to mix them up. If setup.py ran under Python 3 but you're running test.py with Python 2, the module won't be found.

  • Run test.py explicitly with Python 3:
    python3 test.py
    
  • To confirm which version setup.py used, look back at its output—you'll see lines mentioning "Python 3.x" if that's the case.

2. Reinstall the ACRCloud Module (Cleanly)

Sometimes setup.py finishes without errors but leaves a partial or corrupted installation. Try a force reinstall:

# If you installed via pip
pip3 install acrcloud --force-reinstall

# If you installed from the source repo
cd path/to/your/acrcloud-sdk-python-folder
pip3 install . --force-reinstall

Using pip3 ensures you're targeting Python 3, which is almost certainly what you want.

3. Verify Dependencies Are Installed

ACRCloud relies on other modules (like requests or pycryptodome), and these might fail to install silently on Raspberry Pi's ARM chip. Check if the missing module is a dependency by looking at the full ImportError message (it will say something like No module named 'requests'). Install it directly:

pip3 install requests pycryptodome

4. Add the Module to Your Python Path

If the ACRCloud module is installed in a directory that Python doesn't check by default, you can manually add it in test.py. First, find where the module is installed:

python3 -c "import acrcloud; print(acrcloud.__file__)"

Then add the parent directory to the path at the top of test.py:

import sys
sys.path.append('/path/to/the/parent/directory')

Quick Tip: Always share the full text of the ImportError if you need more specific help—it tells us exactly which module is missing, making the fix way faster!

内容的提问来源于stack exchange,提问作者Adam Wojciak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:07:38