尝试运行使用pyaudio的python应用程序。使用virtualenv和安装正在运行。但是在运行时无法找到portaudio。但_portaudio.so文件存在。任何建议???
(venv) kidkic@pi-mirror1:~/audio $ jasper/jasper.py
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "jasper/jasper.py", line 31, in <module>
from client.mic import Mic
File "/home/kidkic/audio/jasper/client/mic.py", line 9, in <module>
import pyaudio
File "/home/kidkic/audio/venv/local/lib/python2.7/site-packages/pyaudio.py", line 116, in <module>
import _portaudio as pa
ImportError: /home/kidkic/audio/venv/local/lib/python2.7/site-packages/_portaudio.so: undefined symbol: Pa_GetStreamReadAvailable
# CHECKING THAT THE FILE EXISTS (a binary file)
(venv) kidkic@pi-mirror1:~/audio $ ls venv/local/lib/python2.7/site-packages/_*
venv/local/lib/python2.7/site-packages/_portaudio.so
答案 0 :(得分:6)
问题不在于它找不到库,而是库缺少所需的功能。 (source code)。我遇到了同样的问题,并认为问题源于使用错误版本的portaudio-dev
进行构建。
您需要做什么:
sudo apt-get purge --remove python-pyaudio
,请用./configure
卸载python-pyaudio(这是版本0.2.8)make
make install
portaudio19-dev
python-all-dev
python3-all-dev
( Python 3 的sudo pip install pyaudio
)之后,我能够使用pyaudio。
答案 1 :(得分:3)
这对我有用
conda install -c anaconda portaudio
答案 2 :(得分:1)
对于Linux用户,在安装Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
PortAudio was successfully installed.
On some systems (e.g. Linux) you should run 'ldconfig' now
to make the shared object available. You may also need to
modify your LD_LIBRARY_PATH environment variable to include
the directory /usr/local/lib
sudo ldconfig
所以,我想按照Wehrdo的上述回答中的步骤,将以下命令添加为步骤4。
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/custom/path/" >> ~/.bashrc
var check = !$.trim( $('#div').html() ).length;
if (check) {
console.log('no html');
} else {
console.log('some html');
}
答案 3 :(得分:0)
当我用 conda 安装 pyaudio 时,错误就出来了。但是,当我通过 'pip install pyaudio' 用 pip 安装它时它就消失了
这个包的 conda 源似乎有问题。
答案 4 :(得分:0)
问题是目前python 2.7、3.4、3.5和3.6主要支持portaudio和pyaudio。在您提出问题时,可能不支持 2.7。如果你想知道哪些版本的 python 是兼容的,你总是必须检查这个网站:https://pypi.org/project/PyAudio/#files。如果你想保持你的 python 版本相同,试试这个非官方的 Windows 站点:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
答案 5 :(得分:-2)
Pip Unistall pyaudio Pipwin安装pyaudio 对于Windows机器