I met this issue in caddy installation. It requires repo ‘copr’ and get an error in yum importing.
I searched on google and find that most of this issue is caused by missing or broken of urllib3
[root@localhost ~]# yum copr enable @caddy/caddy
Plugin "copr" can't be imported
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
No such command: copr. Please use /usr/bin/yum --help
Work:
[root@localhost ~]# ls /usr/lib/yum-plugins/
This is to find whether copr repo is installed. If so, here will be the copr.py, copr.pyc and copr.pyo in response.
copr.py fastestmirror.py product-id.py search-disabled-repos.py subscription-manager.py
copr.pyc fastestmirror.pyc product-id.pyc search-disabled-repos.pyc subscription-manager.pyc
copr.pyo fastestmirror.pyo product-id.pyo search-disabled-repos.pyo subscription-manager.pyo
then cd to this path, start python and import copr.
[root@localhost yum-plugins]# python
Python 2.7.5 (default, Jun 28 2022, 15:30:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import copr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "copr.py", line 29, in <module>
import requests
File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/lib/python2.7/site-packages/requests/utils.py", line 32, in <module>
from .exceptions import InvalidURL
File "/usr/lib/python2.7/site-packages/requests/exceptions.py", line 10, in <module>
from urllib3.exceptions import HTTPError as BaseHTTPError
ImportError:
>>>
KeyboardInterrupt
>>> No module named urllib3.exceptions
File "<stdin>", line 1
No module named urllib3.exceptions
^
SyntaxError: invalid syntax
Seems something went wrong with urllib3, try to install it
[root@localhost yum-plugins]# pip install urllib3
Requirement already satisfied: urllib3 in /usr/local/lib/python3.6/site-packages (1.26.12)
We already have urllib3 but this the response is from pip of python3 and yum works with python2. So, the actual command is:
[root@localhost yum-plugins]# pip2 install urllib3
Or
[root@localhost yum-plugins]# pip2 install --upgrade urllib3
Collecting urllib3
Using cached https://files.pythonhosted.org/packages/6f/de/5be2e3eed8426f871b170663333a0f627fc2924cc386cd41be065e7ea870/urllib3-1.26.12-py2.py3-none-any.whl
Installing collected packages: urllib3
Found existing installation: urllib3 1.10.2
Uninstalling urllib3-1.10.2:
Successfully uninstalled urllib3-1.10.2
Successfully installed urllib3-1.26.12
something changed, so try import copr again:
[root@localhost yum-plugins]# python
Python 2.7.5 (default, Jun 28 2022, 15:30:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import copr
>>>
yum copr enable @caddy/caddy
Loaded plugins: copr, fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
You are about to enable a Copr repository. Please note that this
repository is not part of the main Fedora distribution, and quality
may vary.
The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr>, and
packages are not held to any quality or securty level.
Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.
Do you want to continue? [y/N]: y
copr done
Worked with python and yum.