我正在尝试运行一个使用 pyaudio 的 Python 程序:
- 我下载了程序(从 Github下载,因为 .deb 太旧了)
- 我安装
python-pyaudio
- 我运行程序
- 节目说
ImportError: No module named 'pyaudio'
我究竟做错了什么?
$ sudo apt-get install python-pyaudio
[sudo] password for nico:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
python-pyaudio-doc
The following NEW packages will be installed:
python-pyaudio
0 upgraded, 1 newly installed, 0 to remove and 49 not upgraded.
Need to get 0 B/24.1 kB of archives.
After this operation, 109 kB of additional disk space will be used.
Selecting previously unselected package python-pyaudio.
(Reading database ... 336001 files and directories currently installed.)
Preparing to unpack .../python-pyaudio_0.2.8-1build2_amd64.deb ...
Unpacking python-pyaudio (0.2.8-1build2) ...
Setting up python-pyaudio (0.2.8-1build2) ...
$ ./runanki
Traceback (most recent call last):
File "./runanki", line 3, in <module>
import aqt
File "/home/nico/src/anki/aqt/__init__.py", line 4, in <module>
from anki import version as _version
File "/home/nico/src/anki/anki/__init__.py", line 13, in <module>
from anki.storage import Collection
File "/home/nico/src/anki/anki/storage.py", line 12, in <module>
from anki.collection import _Collection
File "/home/nico/src/anki/anki/collection.py", line 26, in <module>
from anki.sound import stripSounds
File "/home/nico/src/anki/anki/sound.py", line 207, in <module>
import pyaudio
ImportError: No module named 'pyaudio'
环境:
$ which python
/usr/bin/python
$ python --version
Python 2.7.11+
问题的原因是https://github.com/dae/anki/blob/master/runanki
runanki
上的脚本的 shebang明确声明了 Python 3,因此调用了 Python 3 解释器,但您已经为 Python 2安装了。结果,Python 3 无法找到,因此引发了. 这里最简单的解决方案是通过运行安装 Python 3 绑定:./runanki
pyaudio
pyaudio
ImportError
pyaudio