'Can't install packages via pip, with error: ERROR: Could not find a version that satisfies the requirement, but can import via python console?

I am getting essentially the same errors on multiple packages install via pip on Ubuntu 20.04 using python3.8.10: ERROR: Could not find a version that satisfies the requirement (from versions: none) ERROR: No matching distribution found for

However, if I run python3 in the console, i can import these packages that are not shown up on pip list and can't be installed. How to fix?:

python3


    Python 3.8.10 (default, Mar 15 2022, 12:22:08)
    [GCC 9.4.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import socket
    >>> import logging
    >>> import re
    >>> import traceback
    >>> import subprocess
    >>> dir(subprocess)
    ['CalledProcessError', 'CompletedProcess', 'DEVNULL', 'PIPE', 'Popen', 'STDOUT', 'SubprocessError', 'TimeoutExpired', '_PIPE_BUF', '_PopenSelector', '_USE_POSIX_SPAWN', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_active', '_args_from_interpreter_flags', '_cleanup', '_mswindows', '_optim_args_from_interpreter_flags', '_posixsubprocess', '_time', '_use_posix_spawn', 'builtins', 'call', 'check_call', 'check_output', 'contextlib', 'errno', 'getoutput', 'getstatusoutput', 'io', 'list2cmdline', 'os', 'run', 'select', 'selectors', 'signal', 'sys', 'threading', 'time', 'warnings']
    >>>

Please advise on how to fix it so Pip would synch with what i am able to import at runtime, ie. python console.

Do i need to set PYTHONPATH variable?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source