简体   繁体   中英

Can't import PyAudio to PyCharm project

I can access it in the terminal but when I try to add it to my python project in PyCharm it won't let me I have tried with both python 3.10 and 3.9

it also shows this when i ask for details on why it doesn't work

Collecting PyAudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
Building wheels for collected packages: PyAudio
  Building wheel for PyAudio (setup.py): started
  Building wheel for PyAudio (setup.py): finished with status 'error'
  Running setup.py clean for PyAudio
Failed to build PyAudio
Installing collected packages: PyAudio
    Running setup.py install for PyAudio: started
    Running setup.py install for PyAudio: finished with status 'error'

  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Lenovo\PycharmProjects\Alexa2\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Lenovo\\AppData\\Local\\Temp\\pip-install-bl692lay\\pyaudio_da329c95486d497b95d33a9225fb1595\\setup.py'"'"'; __file__='"'"'C:\\Users\\Lenovo\\AppData\\Local\\Temp\\pip-install-bl692lay\\pyaudio_da329c95486d497b95d33a9225fb1595\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Lenovo\AppData\Local\Temp\pip-wheel-qtpqe2of'
       cwd: C:\Users\Lenovo\AppData\Local\Temp\pip-install-bl692lay\pyaudio_da329c95486d497b95d33a9225fb1595\
  Complete output (11 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.10
  copying src\pyaudio.py -> build\lib.win-amd64-3.10
  warning: build_py: byte-compiling is disabled, skipping.
  
  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
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Lenovo\PycharmProjects\Alexa2\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Lenovo\\AppData\\Local\\Temp\\pip-install-bl692lay\\pyaudio_da329c95486d497b95d33a9225fb1595\\setup.py'"'"'; __file__='"'"'C:\\Users\\Lenovo\\AppData\\Local\\Temp\\pip-install-bl692lay\\pyaudio_da329c95486d497b95d33a9225fb1595\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Lenovo\AppData\Local\Temp\pip-record-p3n5y632\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Lenovo\PycharmProjects\Alexa2\venv\include\site\python3.10\PyAudio'
         cwd: C:\Users\Lenovo\AppData\Local\Temp\pip-install-bl692lay\pyaudio_da329c95486d497b95d33a9225fb1595\
    Complete output (11 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.10
    copying src\pyaudio.py -> build\lib.win-amd64-3.10
    warning: build_py: byte-compiling is disabled, skipping.
    
    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:\Users\Lenovo\PycharmProjects\Alexa2\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Lenovo\\AppData\\Local\\Temp\\pip-install-bl692lay\\pyaudio_da329c95486d497b95d33a9225fb1595\\setup.py'"'"'; __file__='"'"'C:\\Users\\Lenovo\\AppData\\Local\\Temp\\pip-install-bl692lay\\pyaudio_da329c95486d497b95d33a9225fb1595\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Lenovo\AppData\Local\Temp\pip-record-p3n5y632\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Lenovo\PycharmProjects\Alexa2\venv\include\site\python3.10\PyAudio' Check the logs for full command output.
WARNING: You are using pip version 21.1.2; however, version 22.0.3 is available.
You should consider upgrading via the 'C:\Users\Lenovo\PycharmProjects\Alexa2\venv\Scripts\python.exe -m pip install --upgrade pip' command.

edit: now it says:

Command errored out with exit status 1

rather then the warning about c++ visual tools

The error indicates 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: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ . You should install this to proceed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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