本文介绍了PyAudio不会在Windows上导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用pip来安装PyAudio,但是当我尝试使用 import pyaudio
导入它时,出现以下错误消息
I have used pip to install PyAudio, yet when I try to import it using import pyaudio
, I get the following error message
我试图重新安装PyAudio,并说我已经安装了它.
I tried to reinstall PyAudio, and it says that I already have it installed.
推荐答案
- 请确保您使用的是
import pyaudio
,而不是import PyAudio
(如错误消息所示).Python区分大小写. - 如果您的计算机上安装了多个Python环境,也可能导致这种情况.
- Please ensure you use
import pyaudio
, and notimport PyAudio
(as the error message suggests). Python is case sensitive. - This scenario can also be caused if you have multiple Python environments installed on your machine.
可以通过以下方式检查某些环境问题-打开 cmd
并运行:
Some of the environment problems can be checked in the following way - open cmd
and run:
where python
where pip
pip应该与Python在脚本"文件夹下的目录相同.
pip should be in the same directory as Python, under the "Scripts" folder.
如果您发现pip的路径和Python的路径完全不同,则可能的解决方案是:
If you find that the path to pip and the path to Python are completely different, some possible solutions are:
- 使用
cd
在cmd中更改当前工作目录.使其指向正确的pip
的位置.然后运行pip install
. - 删除重复的Python环境.如果您需要多个环境,请使用可用的Python虚拟环境解决方案之一(
conda
,virtualenv
等)
- Change your current working directory in the cmd using
cd
. Make it point to the location of the correctpip
. Then runpip install
. - Remove the duplication of your Python environments. If you need more than one environment, use one of the available Python virtual environment solution (
conda
,virtualenv
etc)
这篇关于PyAudio不会在Windows上导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!