Pip can't install any package - python-3.x

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

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"

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.

I ran into this issue due to the SSLKEYLOGFILE environmental variable in windows (used for tls decryption) if set to an invalid path also causes this error in python where other software will ignore the missing file.

There seems to be a problem with pip 20.3:
https://github.com/pypa/pip/issues/9190
I have downgraded to 20.2.4 and it worked for me.
(I know it cannot be the cause of the original problem, but I think this page is visited also by people currently experiencing the problem)

In case problem persists behind a proxy, you may find this solution helps, like:
conn.tls_in_tls_required = False
at \Lib\site-packages\pip\_vendor\urllib3\connectionpool.py

I have used this, It was installed automatically.
python.exe -m pip install upgrade robotframework-seleniumlibrary --proxy="proxy:port

Related

pip is configured with locations that require TLS/SSL while installing numpy in VSCode virtual environment

I got the error:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
while trying to install numpy inside a virtual environment in visual studio code. I have noticed the following:
If I do "pip install numpy" outside the virtual environment in VS code, everything is fine.
While I use "py -3 -m venv NameOfVirtualEnvironment" to create the virtual environment in VS code, no .vscode file is created.
I couldn't do "pip install SSL" or any other rememdies to fix the problem as recommended in the previous similar posts.
I can "pip install numpy" in a command window smoothly.
Here is the detailed error message I got:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting numpy
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
I got the same error trying to use Python 3.9.7 from Miniconda together with Microsoft's Python extension for Visual Studio Code. The error was resolved by the following steps:
Install a version of Python (I installed Python 3.10.0) from https://www.python.org/downloads/, as supported by the extension according to its installation instructions.
Choose that Python installation using CTRL-SHIFT-P → Python:Select Interpreter.

Cannot pip install with python 2,7 virtual environment

I am trying to use the following OCR project that is found here on github. I am using python 3 virtual environment. I am on Windows. I installed successfully requirements.txt using Python 3.6.7, however when I am attempting to do python install setup.py I get the following error:
AssertionError: you must install and use OCRopus with Python version 2.7 or later, but not Python 3.x
Having this said, I reverted back and tried to use Python 2.7 with the virtual environment using pyenv-win link. When I try to install requirements.txt with the virtual env of python 2.7 I get the following error:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:380: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning,
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning,
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning,
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning,
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning,
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning,
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)) - skipping
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning,
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)) - skipping
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning,
(ocropus)
Does that mean I cannot install these python packages at all using python 2.7 ? I have to use this repository for my project.
For anyone who stumbles upon this in the future, ocropy needs Python 2.7 but numpy and scipy newest versions dropped Python 2.7 support. However, you can still use them but the problem is that our developer folks will stop supporting bug fixes.
My problem was mainly the global version of Python I have on my system (windows) is 3.6.7 while ocropus requires 2.7. I downloaded a broken executable for Python 2.7 that did not have the Scripts folder installed, thus pip ended up not working at all.
Followed this tutorial that shows how to install another version of python (2.7) and the problem was solved when I downloaded the following executable
In order to use thevirtualenv properly with python 2.7 use the following command
# dont forget to add python.exe
virtualenv -p C:\Python27\python.exe venv/ocropus
Goodluck.
Read your error again, and you will see this at the 2nd line of your error:
This may cause the server to present an incorrect TLS certificate,
These all errors are SSL warnings, and as stated in error, python is telling you to upgrade python to python 3, but as the OCR project uses python version 2, so you have two solutions:
Either, Manually download the requirements and install them
Or, leave OCR project because python 2 is old now, no longer supported
I hope i have answered your question

How to install python packages in cmd?

I have been trying to install some packages from last two days. But I couldn't able to succeed in that. The only error I am getting, when I tried to install packages through pip in cmd is :
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 405 Method Not Allowed',))': /simple/numpy/
Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy
I tried to find the solution on different platform, but I couldn't succeed in that.
I am using company network. Might be that is the problem, but I am not sure.
Could anyone help me with this?From last two days, I am sick of it.
Thanks in advance
It's most definitely your company network. A viable solution would be to run:
export http_proxy=company-proxy:8000
export https_proxy=company-proxy:8000
After that confirm you have outgoing network:
curl https://www.google.com/
The above should display a long html output.
For this to work you'll have to ask the systems admin for a proxy you can use.

Issues Installing with Pip3

I am running into a strange issue that I have not been able to find a solution for yet.
I have just installed Ubuntu-Budgie on a new system and I am setting up a dev environment using Python 3.6, but for some reason pip3 is not installing packages in my project when I run pip3 install, it just hangs.
pip3 install django
Collecting django
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/django/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/django/
I have uninstalled and reinstalled pip3, restarted my pc, and nothing seems to be working and I am drawing a blank on what to do next.
I am not connecting through a proxy, this is just standard internet, and I can successfully ping other sites and view the internet so it should not be an overall connection issue. Does anybody have an idea?
Update
pip3 install django -vvv
Collecting django
1 location(s) to search for versions of django:
* https://pypi.python.org/simple/django/
Getting page https://pypi.python.org/simple/django/
Looking up "https://pypi.python.org/simple/django/" in the cache
Returning cached "301 Moved Permanently" response (ignoring date and etag information)
Looking up "https://pypi.org/simple/django/" in the cache
No cache entry available
Starting new HTTPS connection (1): pypi.org
Incremented Retry for (url='/simple/django/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/django/
Starting new HTTPS connection (2): pypi.org
This exact same thing happened to me the other day. I figured it was an internet problem but I could ping from terminals and access web on the browser. But as it turned out it was a web problem and after I restarted my PC it worked just fine.
I tried it out again, it just reset on its own when it found a proper internet connection(my internet here is a bit shoddy).
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\Users\SUMUKHAs PC> pip install django Collecting django Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000237E11C7FD0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/django/ Operation cancelled by user PS C:\Users\SUMUKHAs PC> pip install scikit-learn Collecting scikit-learn Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/scikit-learn/ Downloading https://files.pythonhosted.org/packages/74/fc/e3d24a3472e32102f9f667adf05a41fdd5b56893f34464f06c8549684cd5/scikit_learn-0.20.1-cp37-cp37m-win_amd64.whl (4.8MB) Operation cancelled by user PS C:\Users\SUMUKHAs PC> pip install scikit-learn Collecting scikit-learn Downloading https://files.pythonhosted.org/packages/74/fc/e3d24a3472e32102f9f667adf05a41fdd5b56893f34464f06c8549684cd5/scikit_learn-0.20.1-cp37-cp37m-win_amd64.whl (4.8MB) 9% |███ | 471kB 2.7kB/s eta 0:26:16

PyCharm cannot find existing Matplotlib installation or install new one

I am trying to run and debug Python scripts with PyCharm that use Matplotlib plots. However I can't do either because PyCharm can't find my existing Matplotlib installation, and fails to download and install it's own version when I try to install Matplotlib through the settings/package manager interface.
However, I already have Matplotlib installed on my computer, and when I run the script through terminal, everything works just fine.
So my question is, how can I either:
Successfully install Matplotlib through PyCharm or
Direct PyCharm to my existing Matplotlib installation
System versions
OS: Ubuntu 14.04
Python: 3.7.0 (3.4 also installed)
Pip: 18.1 from /usr/local/lib/python3.4/dist-packages/pip (python 3.4)
Pip3: 18.1 from /home/matt/anaconda3/lib/python3.7/site-packages/pip (python 3.7)
Matplotlib: 3.0.2
PyCharm: PyCharm community v 2018.3.1
PyCharm interpreter: Python 3.7
Error when installing Matplotlib through PyCharm
Collecting matplotlib==3.0.2
Could not fetch URL https://pypi.org/simple/matplotlib/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/matplotlib/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/matplotlib/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/matplotlib/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/matplotlib/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/matplotlib/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/matplotlib/
Could not find a version that satisfies the requirement matplotlib==3.0.2 (from versions: )
No matching distribution found for matplotlib==3.0.2
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Ubuntu 14.04 doesn't include OpenSSL 1.0.2 or higher, which is now required by Python 3.7. This means the ssl module of python will not be built in. Without the ssl module pip is unable to download packages from the repositories.
If you configure pycharms to use your system version of python (3.4) which is what will be used by the terminal you should be fine to get matplotlib.
My recommendation would be to upgrade to 16.04 or later.

Resources