-1

I want to upgrade pip to python 3.8, but I got error

# python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip
WARNING: The directory '/home/super/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: 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/pip/
WARNING: 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/pip/
WARNING: 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/pip/
WARNING: 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/pip/
WARNING: 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/pip/
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
Requirement already up-to-date: pip in /usr/local/lib/python3.8/site-packages (20.2.3)
WARNING: 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


# pip --version
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal.cli.main import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 58
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

# python --version
Python 3.8.9

Another upgrade pip solution also see the same error below.

# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py


% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1892k  100 1892k    0     0  5629k      0 --:--:-- --:--:-- --:--:-- 5615k
root@py-dev:~/music/pip# python3.8 get-pip.py
/usr/local/lib/python3.8/site-packages/setuptools/distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
  warnings.warn(
WARNING: The directory '/home/super/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: 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/pip/
WARNING: 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/pip/

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
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)

How to fix it?

os version : ubuntu 16

python version: 3.8

敬錞 潘
  • 852
  • 1
  • 14
  • 29
  • 1
    You have 2 separate issues: 1) for the SSL issue: [SSLError(“Can't connect to HTTPS URL because the SSL module is not available.”) in pip command](https://stackoverflow.com/q/63084049/2745495), 2) for the pip syntax error issue, you seem to have an old version of pip: [Python Pip broken with sys.stderr.write(f“ERROR: {exc}”)](https://stackoverflow.com/a/65928602/2745495) – Gino Mempin Jul 19 '21 at 08:30
  • 1
    Does this answer your question? [SSLError("Can't connect to HTTPS URL because the SSL module is not available.") in pip command](https://stackoverflow.com/questions/63084049/sslerrorcant-connect-to-https-url-because-the-ssl-module-is-not-available) – Gino Mempin Jul 19 '21 at 08:30

1 Answers1

0

Have you tried running the command as sudo ? It says that you can't use SSL/TLS with python, maybe provide a http source.

In fact you should see this post that may be usefull for you : pip install fails with "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)"

nyandog26
  • 1
  • 2
  • already try use sudo, the same error. and how to change http source – 敬錞 潘 Jul 19 '21 at 08:27
  • 1
    The directory `/home/super` looks suspicious; it seems like you are running as `root` (because you have a `#` prompt, in which case `sudo` is completely pointless) but have $HOME point to a regular user's home directory. – tripleee Jul 19 '21 at 08:39
  • @tripleee yes, I run as root – 敬錞 潘 Jul 19 '21 at 09:37
  • 1
    So then the `sudo` is completely pointless, and the real question is how exactly you acquired `root`. – tripleee Jul 19 '21 at 09:39