简体   繁体   English

我正在使用 python 3.9,但我不知道如何在我的 Windows 10 中安装 pyaudio

[英]I am using python 3.9 and I can't figure out how to install pyaudio in my Windows 10

Currently using Visual Studio Code Tried using pip install pyaudio but it simply gave an error like:当前使用 Visual Studio Code 尝试使用pip install pyaudio但它只是给出了如下错误:

PS C:\Users\NIKHIL> pip install pyaudio
Defaulting to user installation because normal site-packages is 
not writeable
Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
Building wheels for collected packages: pyaudio
  Building wheel for pyaudio (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"'; __file__='"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"';f=getattr(tokenize, 
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\NIKHIL\AppData\Local\Temp\pip-wheel-cbxwzcr9'
       cwd: C:\Users\NIKHIL\AppData\Local\Temp\pip-install-yo0mmwlt\pyaudio_d4ca14ee2a5246debede93cab086f909\
  Complete output (9 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  copying src\pyaudio.py -> build\lib.win-amd64-3.9
  running build_ext
  building '_portaudio' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for pyaudio
  Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
    Running setup.py install for pyaudio ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"'; __file__='"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\NIKHIL\AppData\Local\Temp\pip-record-u900rrya\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\NIKHIL\AppData\Roaming\Python\Python39\Include\pyaudio'  
         cwd: C:\Users\NIKHIL\AppData\Local\Temp\pip-install-yo0mmwlt\pyaudio_d4ca14ee2a5246debede93cab086f909\
    Complete output (9 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    copying src\pyaudio.py -> build\lib.win-amd64-3.9
    running build_ext
    building '_portaudio' extension
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"'; __file__='"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\NIKHIL\AppData\Local\Temp\pip-record-u900rrya\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\NIKHIL\AppData\Roaming\Python\Python39\Include\pyaudio' Check the logs for full command 
output.

please suggest a way out of this请提出解决办法

You can also try to install it with the.whl file.您也可以尝试使用 .whl 文件安装它。

  1. Find your Python version查找您的 Python 版本
  2. 64 or 32 bit? 64 位还是 32 位?
  3. Find the appropriate file here For example, my Python version is the 3.9 64bit I would download the "PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl" file.这里找到合适的文件 例如,我的 Python 版本是 3.9 64bit 我会下载“PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl”文件。
  4. Open your CMD and go to the folder where the file is.打开 CMD 和 go 到文件所在的文件夹。 Ex.: cd C:\Users\Miguel\Downloads例如:cd C:\Users\Miguel\Downloads
  5. Install it: pip install PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl安装它:pip install PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl

Hope it helped!希望它有所帮助!

This answer from a StackOverflow question might help, as I had the same problem and it solved the problem for me.这个来自 StackOverflow 问题的答案可能会有所帮助,因为我遇到了同样的问题,它为我解决了这个问题。

First run your IDE or CMD as Administrator and run the following:首先以管理员身份运行 IDE 或 CMD 并运行以下命令:

 pip install pipwin pipwin install pyaudio

Try these commands below:试试下面的这些命令:

pip install pipwin

pipwin install pyaudio

Looking at the error message it seems you require Visual C++ build tools.查看错误消息,您似乎需要 Visual C++ 构建工具。

The link to download that is also given within that error message.该错误消息中还提供了下载链接。

In case the link does not work,You can download it here: https://visualstudio.microsoft.com/visual-cpp-build-tools/如果链接失效,可以在这里下载: https://visualstudio.microsoft.com/visual-cpp-build-tools/

You can try this and incase errors still persist, reply to this thread.你可以试试这个,如果错误仍然存在,请回复这个帖子。

Upvote if it helped!有帮助就点个赞吧!

PyAudio just doesn't have the wheels for Python 3.7 or higher. PyAudio只是没有用于 Python 3.7或更高版本的轮子。 If you want to use PyAudio , it is best to download python version 3.6.9 here .如果你想使用PyAudio ,最好在这里下载 python 3.6.9版本。

I wish you the best -arivvid27祝你一切顺利-arivvid27

I tried with Python 3.9 and didn´t work, so I installed Python 3.8 too and pyaudio worked fine (I've double checked and downloaded both versions of pyaudio on https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio ). I tried with Python 3.9 and didn´t work, so I installed Python 3.8 too and pyaudio worked fine (I've double checked and downloaded both versions of pyaudio on https://www.lfd.uci.edu/~gohlke/pythonlibs /#pyaudio )。 I still don't know why it doesn't work on 3.9.我仍然不知道为什么它在 3.9 上不起作用。 Did it work for someone on python 3.9?它对 python 3.9 上的某人有用吗? If yes, let me know what did you do.如果是,请告诉我你做了什么。 Thanks!谢谢!

you should use python 3.6.9 or lower您应该使用 python 3.6.9 或更低版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM