How To Install Any Python Library
How to install any Python Library 2021 without any Error
Welcome back! Python is the most demanding language of this era, and it is still going on rapidly. I am also a Python lover due to its syntax, huge community, ocean of libraries and a lot more that is not the main topic of this article. As we know, we can perform a lot of different tasks with the help of Core Python or using its supported libraries. For example, we can use Pandas for various tasks like data cleaning etc. Likewise, there are a lot of Python libraries that can be used for a lot of different purposes. Moving to the point without any further features of Python and its libraries.
A lot of libraries can be installed directly using pip or anaconda with good stable internet access. However, some libraries require a high-speed stable internet connection for installation like TensorFlow, CMUSphinx etc. For the last some days, I was trying to install TensorFlow and CMUSphinx for my project but could not install them due to an unstable or slow internet connection and was getting errors like this:
Note: Kindly read your Error first and try to install prerequisite libraries or tools before installing your desired library. For example, some Python libraries require Microsoft Visual C++ Redistributable. Thus, make sure that you have installed all the prerequisites.
Still, getting errors using pip or anaconda? Let’s install a library from scratch.
Note: Make sure you have installed Python and your pip environment is working well
Method 1: Try installing using pip or anaconda. (We will use pip for this tutorial. You can use Anaconda which can install on slow internet too)
- Open cmd as Administrator
- Run
pip install pocketsphinx
No Error! Congratulations. You don’t need to test further procedures.
Got Error! Like this
Let’s try the method that will resolve these issues
Get ARHAM RUMI’s stories in your inbox
Join Medium for free to get updates from this writer.
Method 2: Using Wheel File
- Open
cmdas Administrator - Run
pythonto see your Python version and your CPU architecture. For example
Here we can see that our Python version is 3.9 and CPU architecture is 64-bit
- Go to Unofficial Windows Binaries for Python Extension Packages site that has all the Python libraries in
.whlfile format. - Navigate to your desired library. For example
pocketsphinxin our case. - Choose the file compatible with your Python version and CPU architecture. Click on the chosen file, and it will start downloading.
Note: Here 3.9 is the same as 39 and also for all versions
- Move to the directory where you have downloaded the desired library wheel file. In my case, it’s the default downloads location on Windows 10
- Open cmd and move to the download location, or you can simply go to the downloads directory and then in the address bar type cmd and hit Alt+Shift+Enter, this will do the same work.
- Run
pip install pocketsphinx-0.1.15-cp39-cp39-win_amd64.whl
You have to replace the file name with the one you have downloaded
That’s all. Now you can test if you have installed your required library successfully by applying the same procedure as described in Method 1. You will get a result similar to this
Not getting errors while using your recently installed library in your projects? Congratulations! You are done.
Alas! Still getting errors while using that library. Let’s modify the above method a little for your project.
I am using Pycharm for this. You can also perform the same in the terminal of your IDE.
- Open Terminal in your IDE
- Type
pip install, But don’t run it at this moment - Copy the path from properties of downloaded wheel file and paste it here in the terminal after
pip install - Copy file name and paste it after inserting
\ - Run this whole command
pip install C:\Users\arham\Downloads\pocketsphinx-0.1.15-cp39-cp39-win_amd64.whlIt should look like this
That’s all for today. Hope so, this way will resolve a lot of your problems.









