Unable to install PyAudio in VS code [duplicate] - python

I am having issues installing PyAudio and portaudio.
When I do python -m pip install pyaudio I get this error:
src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
Command ""C:\Users\This PC\AppData\Local\Programs\Python\Python37-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\THISPC~1\\AppData\\Local\\Temp\\pip-install-3ock7jqh\\pyaudio\\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\THISPC~1\AppData\Local\Temp\pip-record-14pe9p6y\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\THISPC~1\AppData\Local\Temp\pip-install-3ock7jqh\pyaudio\
So after looking that error up, I read I need to install portaudio. So I did python -m pip install portaudio and got this error:
Collecting portaudio
Could not find a version that satisfies the requirement portaudio (from versions: )
No matching distribution found for portaudio
I have no idea where to go from here now.

Try This, CMD as Administrator and run the following:
pip install pipwin
pipwin install pyaudio

portaudio is not a Python package, it's a C library that's entirely independent of Python, so you can't install it via pip.
See the PortAudio for website for details on the official way to get it and install it on your platform.
AFAIK, the official way to get it on Windows is to download the source and then follow the instructions in the Tutorial for compiling it yourself. You probably want to build it with the same compiler you use for Python C extensions, although I'm not sure if that's required.
Or, if you're using a third-party package manager like Chocolatey on Windows, there's a good chance it can install PortAudio.
Or, if you use Anaconda or Miniconda for your Python, the conda package manager knows how to install non-Python packages that Python packages depend on, including portaudio.
Finally, there seem to be a number of people providing unofficial pre-compiled PortAudio binaries for Windows. If you search for "portaudio windows binary" or "portaudio windows pre-compiled" you'll find a number of them. I have no idea how well-tested, up-to-date, etc. any of these are.
If you're using Anaconda/Miniconda, you should have used conda install pyaudio rather than pip install pyaudio in the first place. You should really only use pip for packages that aren't available on conda or conda-forge.
If you haven't set up conda-forge yet, you probably want to do that first:
conda config --add channels conda-forge
And then, this should be all you need:
conda install pyaudio
Unlike the pip package, which just assumes you have portaudio installed properly, the conda package will either automatically install portaudio as a dependency for pyaudio, or tell you why it can't.

The official PyAudio 0.2.11 does not support Python 3.7+, and trying to install results in the error C1083: Cannot open include file: 'portaudio.h'.
However, there are unofficial wheels for PyAudio that support 3.7+.
If you are using the official version, you must use Python 3.6 with PyAudio 0.2.11.
See http://people.csail.mit.edu/hubert/pyaudio/

If you get an error when trying to use pipwin to install this, you have to run it through python as windows doesn't recognize pipwin(at least for me)
pip install pipwin
python -m pipwin install pyaudio

I installed pyaudio on python 3.6.x without problem, but is not working on later versions.
py -m pip install pyaudio
works perfect on 3.6.x or earlier.

You can install Anaconda install pyaudio using it.
You must add Anaconda to path.
After installing Anaconda and adding to path then in your command prompt[cmd] type
conda install pyaudio.
And whala

On Ubuntu distributions you can first run
sudo apt install portaudio19-dev
and then reinstall pyaudio with pip again.

If you are using anaconda then this problem is because your versions are not upgraded.To upgrade all the packages simply run the following command in the terminal.
conda update --all

Use the Following Commands
pip install pipwin
pipwin refresh
pipwin install pyaudio

You can install Portaudio with
pip install port audio
you may also need to
pip install ConfigParser
Let me know if it's work.

Related

Unable to install sftp package in python on my virtual machine

I need to use sftp services through python on my virtual machine.
To note that I am unable to do commands like
pip install packagename
I have limitations on the controlled VM. So I have to download packages and point to local disk locations (pip install C:/Folder/packacgename.whl) to install them so please give me suggestions keeping this in mind.
Trying to install
pip install C:\Windows\pysftp-0.2.9.tar.gz
I needed bycrypt. And trying to install that it said No matching distribution found for setuptools>=40.8.0
I downloaded setuptools and did
pip install C:\Windows\setuptools-59.2.0.tar.gz
I get message
Missing build time requirements in pyproject.toml for file:///C:/Windows/setuptools-59.2.0.tar.gz: 'setuptools' and 'wheel'.
This version of pip does not implement PEP 517 so it cannot build a wheel without 'setuptools' and 'wheel'.
Installing build dependencies ... error
Complete output from command z:\scripts\python.exe -m pip install --ignore-installed --no-user --prefix C:\Users\AppData\Local\Temp\pip-build-env-jmi2p:
ERROR: You must give at least one requirement to install (see "pip help install")
I tried doing
C:\scripts\python.exe -m pip install --upgrade pip
This failed with message pip already up to date
I checked pip version
pip --version
pip 10.0.1 from z:\lib\site-packages\pip (python 3.7)
Manually trying to upgrade pip with tar file I get message setup tools need upgrade
pip install --upgrade C:\Windows\pip-21.3.1.tar.gz
I used --no-binary :all: , this didn’t work.
I have downloaded Microsoft 2015 build tools and installed them as advised by some forum. It didn’t work. I don't really know how to fix this issue. Trying to download PEP517 tar file and installing that does not work as it wants pip to be upgraded. It's like I am going in circles.
You can also use paramiko package for connecting your sftp via Python.
You just have to do
pip install paramiko
Hopefully it works for you.

ERROR: PyAudio-0.2.11-cp38-cp38-win_amd64.whl is not a supported wheel on this platform

I am trying to install pyaudio in python 3.8 and when i execute
pip3 install PyAudio-0.2.11-cp38-cp38-win_amd64.whl
it shows an error that
ERROR: PyAudio-0.2.11-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.
You can try:
pip install pipwin
pipwin install pyaudio
If this doesn't work, you can manually add and install pyaudio.
First, go to: https://www.lfd.uci.edu/~gohlke/pythonlibs/
and check the pyaudio supporting to your Python version.
For example: if you have Python 3.8.2, then PyAudio‑0.2.11‑cp38‑cp38‑win_amd64.whl
After downloading, copy that file and paste it in C://Users/[user]/
Then open cmd and write:
pip install [full filename]
If this doesn't work, change the file directory to
C:\Users\[user]\AppData\Local\Programs\Python\Python38\Scripts
Then restart cmd and run again pip install [full filename].
download pyaudio from:
lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
installing PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl
I have error:
ERROR: PyAudio-0.2.11-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.
But PyAudio‑0.2.11‑cp38‑cp38‑win_amd64.whl
install successful:
pip install .\PyAudio-0.2.11-cp38-cp38-win_amd64.whl
Processing c:\users\sje\downloads\pyaudio-0.2.11-cp38-cp38-win_amd64.whl
Installing collected packages: PyAudio
Successfully installed PyAudio-0.2.11
Check version:
python --version
You need:
py -3.9 -m pip install [name packege]
"-3.9" - own Python version
Example:
py -3.9 -m pip install PyAudio-0.2.11-cp38-cp38-win_amd64.whl
In the case of Mac OSX do:
brew install portaudio
pip install pyaudio
open run and type appdata and go to programs python38 and open file name script in that file past that download 'PyAudio-0.2.11-cp38-cp38-win_amd64' and in that path address click and type cmd and enter open cmd than type pip install PyAudio-0.2.11-cp38-cp38-win_amd64 and enter.
Done
What fixed it for me was upgrading to the latest pip:
pip install --upgrade pip
After that the install succeeded.
Bro, this is a very easy fix. I was playing around with the wheel file directory and I wondered if it would work in the projects venv/scripts directory, and IT WORKS :)
Don't forget to use cmd and use:
pip install (full filename)

How to solve the "pip install pygame" issue?

I am trying to use command pip install pygame in cmd, but there is error.
The error is shown as follows:
C:\Users\Administrator>pip install pygame
Collecting pygame
Using cached https://files.pythonhosted.org/packages/80/2c/3a52e7e9c097229b026b4efbe6711c600f3a84ffdc5f11fd9e7f8932368e/pygame-1.9.6-cp37-cp37m-win32.whl
Installing collected packages: pygame
Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'c:\\program files (x86)\\python37-32\\Lib\\site-packages\\pygame'
Consider using the `--user` option or check the permissions.
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I follow the instruction in the error but still cannot solve the problem. And I also found whatever "pip" command cannot be installed correctly.
You can install the package as Administrator, by following these steps:
1.Right click on the Command Prompt icon
2.Select the option: Run This Program As An Administrator
3.Run the command: pip install pygames
Instead of you can use the command
pip install --user pygames
The other answers didn't work for me. I checked this site and made sure that pip, setuptools, and ez_setup were installed at the latest versions. Still no luck. Finally, I discovered the magic words here:
pip install pygame --pre
Per this, --pre option tells pip to include pre-release versions of packages when searching for the latest version. Apparently that's what's needed as of this writing (2023-02-08).
(Thanks to accddd)
check if Pip was installed correctly by opening a command prompt and entering the following command:
pip -V
output should be like:
pip 18.0 from c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7)
if pip is not install copy this file link and save it to setup.py
now open cmd and run script by typing
python setup.py
for more details check link.
when pip in install correctly install run this commond
python -m pip install -u pygame --user
For this, you have to install pygame package from the cmd (on Windows) or from the terminal (on mac). Just type pip install pygame.If it doesn't work for you, then try using this statement pip3 install pygame. If it is still showing an error then you don't have pip installed on your device and try installing pip first.

How do I install opencv using pip?

I need to install cv2 for a script that has been written for me. I tried pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried pyopenvc and pip install opencv-python.
So, I went to the opencv site and downloaded the relevant exe. Ran it - generated a heap of subdirectories and a make file and stuff.
What do I do now?
Install opencv-python (which is an unofficial pre-built OpenCV package for Python) by issuing the following command:
pip install opencv-python
run the following command by creating a virtual enviroment using python 3 and run
pip3 install opencv-python
to check it has installed correctly run
python3 -c "import cv2"
In pip package management, there are 4 different OpenCV packages all using the same namespace, cv2. Although they are not officially supported by OpenCV.org, they are commonly used in developers' community. You could install any of them using the following command:
pip install PACKAGE_NAME
where PACKAGE_NAME can be
opencv-python (only contains main modules)
opencv-contrib-python (contains both main and contrib modules)
opencv-python-headless (same as opencv-python but without GUI functionality)
opencv-contrib-python-headless (same as opencv-contrib-python but without GUI functionality)
You should only install one of them depending on your needs. If you accidentally installed multiple of them in the same environment, you can remove them using pip uninstall before installing the correct one again.
For more details, you can refer to the project description of OpenCV on Wheels.
As of 2021, all of these 4 packages are official OpenCV projects. Source: OpenCV Website.
To Install the Current Latest version of OpenCV then use the below commands:
Use this Command:
pip install --upgrade opencv-python
If you're facing problem in above command then try this :
pip install --upgrade opencv-contrib-python
To check the version of installed OpenCV:
import cv2
print(cv2.__version__)
Simply use this for the so far latest version 4.1.0.
pip install opencv-contrib-python==4.1.0.25
For the default version use this:
pip install opencv-contrib-python
If you have a new Raspberry Pi and want to install OpenCV then this tutorial would be a good choice.
For Ubuntu/Linux users:
sudo apt install python3-opencv
As of 10/22/2019, I think the best answer is simply
conda install opencv
It appears opencv is now in the main Anaconda channel.
To see which packages (including opencv) are in the main Anaconda channel go to Anaconda Package Lists and follow the link corresponding to your python version and os version.
Everybody struggles initially while installing OpenCV. OpenCV requires a lot of dependencies in the backend. The best way to start with OpenCV is, install it in a virtual environment. I suggest that you use the Python Anaconda distribution and create a virtual environment using it. Then inside the virtual environment, you can install OpenCV using this command:
conda install -c conda-forge opencv
Please follow the command:
pip install opencv-python
then if you want to use:
import cv2
If it's not worked due to any update, please follow the documentation
Make a virtual enviroment using python3
virtualenv env_name --python="python3"
and run the following command
pip3 install opencv-python
to check it has installed correctly run
python3 -c "import cv2"
To install open_cv you can go to this website or do this,
pip install opencv-contrib-python --upgrade
pip install opencv-python
You can test it by:
C:\> python
>>> import cv2
>>> print(cv2.__version__)
'4.5.1' # your version may be a newer one
You can install opencv the normal way:
pip install opencv-python
If you are getting errors, you can do this:
pip install opencv-python-headless
Open anaconda command prompt and type in below command.
conda install -c conda-forge opencv
Once the 'Solving environment' is done. It will ask to download dependencies. Type 'y'.
It will install all the dependencies and then you are ready to code.
I recommend this for Python 3: Please install it this way with pip
pip3 install opencv-python
This will download and install the latest version of OpenCV.
You could try using below command-
pip install opencv-contrib-python
It will basically download the compatible version. If this command fails, you could upgrade you pip using below command-
python -m pip install –upgrade pip
If you need a pictorial guide, head over to Simple Steps to Install OpenCV in Windows
You can also try installing OpenCV from prebuilt binaries from the official OpenCV site.
->pip install opencv-python you can use this.
But if this code does not working then you can check python version on cmd and anaconda because they are different. So you type command in anaconda prompt and cmd, it will work. You can check this -> pip list
Open terminal
Run the following command
pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org opencv-python.
Hope it will work.
Installing cv2 or opencv-python using pip is sometimes a problem. I was having the same problem of installing cv2 with pip. The installation wasn't a problem the problem was to import cv2 after installation. I was getting an Import Error so to fix this i import main from pip to install opencv-python. Try to run the following code in your python file then opencv-python will be installed
from pip._internal import main as install
try:
import cv2
except ImportError as e:
install(["install", "opencv-python"])
finally:
pass
I hope this will help someone
As a reference it might help someone... On Debian system I hard to do the following:
apt-get install -y libsm6 libxext6 libxrender-dev
pip3 install opencv-python
python3 -c "import cv2"
On Ubuntu you can install it for the system Python with
sudo apt install python3-opencv
if you are using Pycharm navigate settings > Project:name > Project interpreter just search the module by name(in this case OpenCV-python) and install it. worked for me
In case you use aarch64 platform with ARM64 cpu - and/or docker
On a development board on ARM64, no python-opencv version were found at all
version: NONE.
I've had to build from source. This allowed to include CUDA support.
In my case it was already available on the board but it wasn't found on the development environment.
If compiling from source is out of reach, there are Dockers
Of course compiling will take some time (few hours on ARM core), but it is worthy process to know as most open source tools can be built this way in case of issues.
I've had this problem in Google Colab, It only worked with this specific package version.
!pip install "opencv-python-headless<4.3"
There are two options-
pip install cv2
or
pip install opencv-python
Hope it helps.

Error installing Jupyter & pywinpty (Python)

I'm trying to install Jupyter on Python 3.7 and seem to be stumbling over this error again and again;
winpty/cywinpty.c(598): fatal error C1083: Cannot open include file: 'winpty.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
I get the same error when attempting to install pywinpty via pip.
I have installed & reinstalled the build tools to no avail and the command window is elevated - any ideas?
UPDATE: Not quite resolved in 3.7 - but it worked fine in 3.6, I've rolled back.
Temporarily, until standard way does not work for Python 3.7, you can install pywinpty manually by using the prebuilt wheel from Gohlke's collection and then install jupyter with pip.
To install manually (from cmd or Powershell) use:
pip install drive:\path\to\the\wheel\pywinpty-0.5.4-cp37-cp37m-win_amd64.whl
I've a concrete solution for you guys... I'm also facing the same issue like you guys as it arises with python3.7 or later versions... But don't worry
I currently have Python 3.9.2
Follow these Steps:-
--> Write these Commands in the cmd
Just install pywinpty by using Gholke s Collection
Now, just download it
Now, copy the path of the file, from where you have downloaded it... In my case it is
After successfully installed Pywinpty... now "pip install jupyter"
Then it's DONE... Now launch the notebook using "jupyter notebook"
In case its not been done... Make a comment below...
There's an easier way to install from Gohlke's collection, which is to use pipwin. Install pipwin using pip install pipwin and then use it in place of pip whenever something doesn't work.
I will leave this option here too. You can install the pywinpty 0.5.7 induvidually and then the rest of the installation can continue.
python -m pip install pywinpty==0.5.7
It worked for me.

Categories