Strange pip error on linux

Second server has strange error , what’s wrong here

Server 1

[root@srv]# python3.6 -m pip show pip
Name: pip
Version: 21.3.1
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: /usr/local/lib/python3.6/site-packages

Server 2

ee@Srv2#python3.6 -m pip show pip
ERROR: Exception:
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 3021, in _dep_map
return self.__dep_map
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 2815, in getattr
raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

more errors…

Welcome!

Please always share the complete traceback. Particularly for this type of error, the part that was omitted contains the key information needed to diagnose and recommend a solution for this issue.

In addition, you should share it in a code block, like this:

```
FULL ERROR TRACEBACK HERE
```

Thanks.

Server 2 full error

python3.6 -m pip show pip


ERROR: Exception:
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 3021, in _dep_map
return self.__dep_map
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 2815, in getattr
raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 3012, in _parsed_pkg_info
return self._pkg_info
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 2815, in getattr
raise AttributeError(attr)
AttributeError: _pkg_info

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/pip/_internal/cli/base_command.py”, line 164, in exc_logging_wrapper
status = run_func(*args)
File “/usr/local/lib/python3.6/site-packages/pip/_internal/commands/show.py”, line 48, in run
results, list_files=options.files, verbose=options.verbose
File “/usr/local/lib/python3.6/site-packages/pip/_internal/commands/show.py”, line 203, in print_results
for i, dist in enumerate(distributions):
File “/usr/local/lib/python3.6/site-packages/pip/_internal/commands/show.py”, line 159, in search_packages_info
required_by = sorted(_get_requiring_packages(dist), key=str.lower)
File “/usr/local/lib/python3.6/site-packages/pip/_internal/commands/show.py”, line 121, in
in {canonicalize_name(d.name) for d in dist.iter_dependencies()}
File “/usr/local/lib/python3.6/site-packages/pip/_internal/metadata/pkg_resources.py”, line 91, in iter_dependencies
return self._dist.requires(extras)
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 2736, in requires
dm = self._dep_map
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 3023, in _dep_map
self.__dep_map = self._compute_dependencies()
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 3032, in _compute_dependencies
for req in self._parsed_pkg_info.get_all(‘Requires-Dist’) or :
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 3014, in _parsed_pkg_info
metadata = self.get_metadata(self.PKG_INFO)
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 1420, in get_metadata
value = self._get(path)
File “/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/init.py”, line 1616, in _get
with open(path, ‘rb’) as stream:
FileNotFoundError: [Errno 2] No such file or directory: ‘/usr/local/lib64/python3.6/site-packages/psycopg2-2.7.6.1.dist-info/METADATA’

Something appears to be broken with your install of the psycopg2 package. If you installed this copy of Python yourself (as I think the fact it is under usr/local suggests you might have), I suggest doing python3.6 -m pip install --force-reinstall psycopg2 to reinstall and hopefully fix it. If that doesn’t work, you can (and usually should) create a virtual environment and install the packages you need there, with

python3.6 -m venv your-env-name
source your-env-name/bin/activate
pip install <the packages you need>
# Etc.

Also, just FYI, Python 3.6 just officially went out of support upstream, and the latest pip 22.0 dropped support for it. Perhaps not an immediate issue, but if you control your installed Python, its probably time to start thinking about upgrading.

Also FYI, for the future, your traceback still wasn’t formatted correct as I instructed above. You can see how it looks in the preview window to the right; if it doesn’t look like my example, it is not correct. In the future, you can simply copy and paste my example, and then paste your traceback inside of it.

tried installing as suggested by you… python3.6 -m pip install --force-reinstall psycopg2

 error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for psycopg2
  Running setup.py clean for psycopg2
Failed to build psycopg2
WARNING: Error parsing requirements for psycopg2: [Errno 2] No such file or directory: '/usr/local/lib64/python3.6/site-packages/psycopg2-2.7.6.1.dist-info/METADATA'
Installing collected packages: psycopg2
  Attempting uninstall: psycopg2
    Found existing installation: psycopg2 2.7.6.1
ERROR: Cannot uninstall psycopg2 2.7.6.1, RECORD file not found. You might be able to recover from this via: 'pip install --force-reinstall --no-deps psycopg2==2.7.6.1'