Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip can't install any package

Tags:

python-3.x

pip

Hello approximately about 2 weeks ago I started not being able to download python packages or even access the pypi website which is "unreachable" on chrome and firefox.

When I try to download a package it gives me this :

$ python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
Collecting numpy
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy

I have no idea why this is happening, I didn't change anything on my computer, it just started to do this one day and on both my computers, I don't understand. Does anybody have any idea why this is happening ? I searched for hours but couldn't find anything to correct this bug.

What I have attempted : - uninstall every python program and reinstall - check my drivers (you never know) - deactivate any proxy - disable my firewall

OS : Windows 10

like image 989
Shraneid Avatar asked Sep 14 '18 09:09

Shraneid


2 Answers

So for anybody searching for a solution, I found this which might not be optimal but at least it works, instead of pip install package use this command

python.exe -m pip install package --proxy="proxy:port"

You can find a big list of free proxies here : https://free-proxy-list.net/ (note that not all of them work and you might wanna try multiple before getting one that works)

So for example you could use : python.exe -m pip install numpy --proxy="179.185.199.195:8080"

like image 117
Shraneid Avatar answered Oct 08 '22 14:10

Shraneid


Using proxy from the previous answer will temporarily make things work - if you find a proxy that doesn't timeout, but it's not fixing the problem and using proxy will hamper your download speeds in most cases.

What I've found is that you need to investigate your Python interpreter location and make sure the venv is not causing problems.

For instance, if setuptools won't update then most likely there is already a part of your code or project that is continually using setuptools - prohibiting it from updating - and other packages need new versions of setuptools to install.

For some reason this then causes "ConnectionResetError: An existing connection was forcibly closed by the remote host" to occur for most packages like tensorflow, keras, pandas etc.

Recreating your venv in another empty location will reset any packages

To do this in Pycharm:

File -> Settings
Project: -> Project Interpreter
Project Interpreter -> drop down list -> show all

Remove your current Python Interpreter location
Add New Environment

Then you will be asked to put in a location for your project: Using a new location here will solve the [Win10054] ConnectionResetError for package installations.

Base Interpreter : point towards your python.exe location ( default usually : C:\Users\UserProfile\AppData\Local\Programs\Python\PythonXX\python.exe and replace XX with your current version and UserProfile with your profile )

Most Important: Because you've setup a new location, install setuptools first, if it's already installed, then upgrade it first. After that you can migrate your code to the new venv and all new packages should work without any connectionResetErrors.

like image 2
Donovan Maree Avatar answered Oct 08 '22 13:10

Donovan Maree