![](/img/trans.png)
[英]Could not import the PyAudio C module '_portaudio'. (Mac M1), about Symbol not found: _PaMacCore_SetupChannelMap
[英]pyaudio could not import _portaudio
嘗試運行使用 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
問題不是它找不到庫,而是庫缺少所需的功能。 ( 源代碼)。 我遇到了同樣的問題,並認為問題源於使用錯誤版本的portaudio-dev
構建。
你需要做什么:
sudo apt-get purge --remove python-pyaudio
如果你有它(這是版本 0.2.8)./configure
make
make install
portaudio19-dev
python-all-dev
( Python 3 的python3-all-dev
)sudo pip install pyaudio
之后,我就可以使用pyaudio了。
這對我有用
conda install -c anaconda portaudio
對於 linux 用戶,您可能會在安裝portaudio
后得到類似的信息
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
因此,我想按照 Wehrdo 上面回答中的步驟添加以下命令作為第 4 步。
sudo ldconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/custom/path/" >> ~/.bashrc
當我使用 conda 安裝 pyaudio 時,出現錯誤。 但是,當我通過“pip install pyaudio”使用 pip 安裝它時它就消失了
這個包的 conda 源似乎有問題。
問題是目前 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
這就是在 M1 MacBook Pro 上對我有用的方法,
conda install -c anaconda portaudio
pip install pyaudio
Pip unistall pyaudio Pipwin install pyaudio For windows machine
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.