Python, 无法安装pyaudio

Python, can not install pyaudio

我正在尝试通过 3 种方式安装 pyaudio 但都失败了:

解决方案 1

pip install pyaudio

当然,它不起作用,但值得一试。

解决方案 2

pip install pipwin
pipwin install pyaudio

这就是我得到的:

Traceback (most recent call last):
  File "C:\Users\Admin\python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Admin\python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Admin\virtualenv\ErzaProject\Scripts\pipwin.exe\__main__.py", line 7, in <module>
  File "C:\Users\Admin\virtualenv\ErzaProject\lib\site-packages\pipwin\command.py", line 98, in main
    cache.install(package)
  File "C:\Users\Admin\virtualenv\ErzaProject\lib\site-packages\pipwin\pipwin.py", line 300, in install
    wheel_file = self.download(requirement)
  File "C:\Users\Admin\virtualenv\ErzaProject\lib\site-packages\pipwin\pipwin.py", line 294, in download
    return self._download(requirement, dest)
  File "C:\Users\Admin\virtualenv\ErzaProject\lib\site-packages\pipwin\pipwin.py", line 290, in _download
    obj.start()
  File "C:\Users\Admin\virtualenv\ErzaProject\lib\site-packages\pySmartDL\pySmartDL.py", line 267, in start
    urlObj = urllib.request.urlopen(req, timeout=self.timeout, context=self.context)
  File "C:\Users\Admin\python\Python37\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\Admin\python\Python37\lib\urllib\request.py", line 525, in open
    response = self._open(req, data)
  File "C:\Users\Admin\python\Python37\lib\urllib\request.py", line 543, in _open
    '_open', req)
  File "C:\Users\Admin\python\Python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Users\Admin\python\Python37\lib\urllib\request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "C:\Users\Admin\python\Python37\lib\urllib\request.py", line 1319, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error timed out>

解决方案 3

pip install PyAudio-0.2.11-cp36-cp36m-win_amd64.whl

结果:

WARNING: Requirement 'PyAudio-0.2.11-cp36-cp36m-win_amd64.whl' looks like a filename, but the file does not exist
ERROR: PyAudio-0.2.11-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.

我什至直接转到这个 page 并在单击文件时出现“ERR_CONNECTION_TIMED_OUT”错误。

不知道是不是主页有问题?还是我系统的问题?还有安装 pyaudio 的方法吗?

(我目前使用的是 win10 64 位)

查看 PyAudio 的 pypi files page,最新的轮子是 Python 3.6。 从您的回溯看来,您似乎是 运行 Python 3.7,所以这是行不通的。 pythonlibs 页面上的 link 对我来说也超时了。

如果pip找不到合适的轮子,它将尝试使用其setup.py编译包。

没办法,自己搭建开发环境,自己编译。 This link 可能会有所帮助。