Have you a faced a situation where you tried to install a Python package, but got a connection timeout error? If so, you are not alone… There could be instances where a firewall prevents an access to install a package using the standard PIP approach. In this short article, I’ll show you one workaround that will allow you to install packages in Anaconda when facing a connection timeout.
Install a package in Anaconda when facing a connection timeout
Normally, If you want to install a Python package in Anaconda, you can then run the Anaconda Prompt and type the following command to install your desired package:
pip install + package name
In the following example, I tried to install the package cx_Oracle:
I then got the following connection timeout error:
Bummer! but luckily there are few workarounds…
If the pip install + package name method did not work for you (perhaps due to a firewall), and you are using Anaconda, you can then try to execute the steps below to bypass this issue:
(1) Search for your desired package by going to The Python Package Index (PyPI).
The ultimate goal is to download the package that you need, and then install it via the Anaconda Prompt using the steps described below.
(2) Now, type the name of the package that you seek in the search bar. Here, I typed in the search bar: cx_Oracle
(3) Click on your desired package. I chose the cx_Oracle 6.2.1 package:
(4) Press on the “Download files” under the Navigation menu:
(5) Click on the version that you wish to download (for example: cx_Oracle-6.2.1-cp36-cp36m-win_amd64.whl):
(6) Place the downloaded file in a location of your choosing. For example, I placed the downloaded file in a folder on my desktop with the following path: C:\Users\Doron E\Desktop\Anaconda
(7) Run the Anaconda Prompt. Then type cd\ and press Enter:
(8) Now type cd + the location where your downloaded file is stored. In my case it was: cd C:\Users\Doron E\Desktop\Anaconda. Then, press Enter:
(9) Type pip install + full file name. Here it is: pip install cx_Oracle-6.2.1-cp36-cp36m-win_amd64.whl
Don’t forget to include the extension of the file name. In our example it’s “.whl”
Then press Enter:
(10) You’ll now notice that the package cx_Oracle was successfully installed: