0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pip2 で module の upgrade しまくったら yum が動かなくなった件

Last updated at Posted at 2021-01-22

pip2 の モジュール周りが古いので Upgrade しまくったら yum が使えなくなった

環境

OS: CentOS 7.9.2009

cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

こんなコマンドを叩くと古いモジュールばかりだった

pip2 list -o
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 pip 21.0 will remove support for this functionality.
Package            Version   Latest    Type
------------------ --------- --------- -----
ansible            2.9.16    2.10.5    sdist
ansible-lint       4.1.0     4.2.0     wheel
ansible-tower-cli  3.3.6     3.3.9     sdist
asn1crypto         0.24.0    1.4.0     wheel
Babel              0.9.6     2.9.0     wheel
cached-property    1.5.1     1.5.2     wheel
certifi            2019.6.16 2020.12.5 wheel
cffi               1.12.3    1.14.4    wheel
chardet            3.0.4     4.0.0     wheel
Click              7.0       7.1.2     wheel
colorama           0.4.1     0.4.4     wheel
configobj          4.7.2     5.0.6     sdist
cryptography       2.7       3.3.1     wheel
decorator          3.4.0     4.4.2     wheel
docker             4.0.2     4.4.1     wheel
docker-compose     1.24.1    1.26.2    wheel
enum34             1.1.6     1.1.10    wheel
idna               2.8       2.10      wheel
iniparse           0.4       0.5       wheel
ipaddress          1.0.22    1.0.23    wheel
IPy                0.75      1.1       sdist
Jinja2             2.7.2     2.11.2    wheel
jmespath           0.9.4     0.10.0    wheel
jsonschema         2.6.0     3.2.0     wheel
kitchen            1.1.1     1.2.6     sdist
langtable          0.0.31    0.0.54    sdist
lmdb               0.92      1.0.0     sdist
MarkupSafe         0.11      1.1.1     wheel
paramiko           2.6.0     2.7.2     wheel
passlib            1.7.1     1.7.4     wheel
ply                3.4       3.11      wheel
pyasn1             0.1.9     0.4.8     wheel
pycparser          2.19      2.20      wheel
pycurl             7.19.0    7.43.0.5  sdist
pygobject          3.22.0    3.36.1    sdist
PyNaCl             1.3.0     1.4.0     wheel
python-dateutil    1.5       2.8.1     wheel
pyudev             0.15      0.22.0    sdist
pyxattr            0.5.1     0.6.1     sdist
PyYAML             3.13      5.4.1     wheel
requests           2.22.0    2.25.1    wheel
ruamel.ordereddict 0.4.14    0.4.15    wheel
ruamel.yaml        0.16.5    0.16.12   wheel
ruamel.yaml.clib   0.1.2     0.2.2     wheel
setuptools         0.9.8     44.1.1    wheel
six                1.12.0    1.15.0    wheel
slip               0.4.0     20191113  sdist
texttable          0.9.1     1.6.3     wheel
urlgrabber         3.10.2    4.1.0     sdist
urllib3            1.25.3    1.26.2    wheel
websocket-client   0.56.0    0.57.0    wheel
wheel              0.33.4    0.36.2    wheel

なんか気持ち悪いので update しまくった

こんなコマンドで一括で upgrade 可能だが依存関係やコンパイルなどで四苦八苦しながら upgrade するはめに

pip2 list -o | tail -n +3 | awk '{print $1}' | xargs pip2 install --upgrade

3時間くらい試行錯誤しながら update を終えると

Oh...... yum が動かない・・・・・・

# yum update
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (none/other)

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

復旧してみる

pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (none/other)

と言われているので、 pycurl の upgrade がまずかったのであろう
とりあえず pycurl を再インストール
参考:yumコマンドを実行するとpycurlでエラーになる

pip2 uninstall pycurl
export PYCURL_SSL_LIBRARY=nss
pip2 install pycurl
Collecting pycurl
  Using cached pycurl-7.43.0.5.tar.gz (216 kB)
Using legacy 'setup.py install' for pycurl, since package 'wheel' is not installed.
Installing collected packages: pycurl
    Running setup.py install for pycurl ... done
Successfully installed pycurl-7.43.0.5

さてどうかな?

yum update
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   cannot import name _bytes_repr

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

Oh..... もっと複雑になった・・・・・・
pycurl のバージョンを指定して再インストールなど何度か色々と試したがさっぱり刃が立たず

pip2 を再インストール

まずは pip2 のモジュールを削除

python -m pip uninstall pip

続いてパッケージの削除とインストール

rpm -ev python2-pip-8.1.2-14.el7
rpm -ivh python2-pip-8.1.2-14.el7.noarch.rpm

さぁどうだ?

yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   cannot import name _bytes_repr

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

だめだった・・・・

モジュールの強制再インストール

仕方ないので「別のマシンで yum が正常に使える pip2 の list と同じモジュールに差し替えよう」とリストを作成
別のマシンで

pip2 list
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 pip 21.0 will remove support for this functionality.
Package                          Version
-------------------------------- ---------
ansible                          2.9.16
ansible-lint                     4.1.0
ansible-tower-cli                3.3.6
asn1crypto                       0.24.0
Babel                            0.9.6
backports.ssl-match-hostname     3.7.0.1
bcrypt                           3.1.7
cached-property                  1.5.1
certifi                          2019.6.16
cffi                             1.12.3
chardet                          3.0.4
Click                            7.0
colorama                         0.4.1
configobj                        4.7.2
cryptography                     2.7
decorator                        3.4.0
docker                           4.0.2
docker-compose                   1.24.1
docker-pycreds                   0.4.0
dockerpty                        0.4.1
docopt                           0.6.2
enum34                           1.1.6
functools32                      3.2.3-2
httplib2                         0.18.1
idna                             2.8
iniparse                         0.4
ipaddress                        1.0.22
IPy                              0.75
Jinja2                           2.7.2
jmespath                         0.9.4
jsonschema                       2.6.0
kitchen                          1.1.1
langtable                        0.0.31
lmdb                             0.92
MarkupSafe                       0.11
paramiko                         2.6.0
passlib                          1.7.1
perf                             0.1
pip                              20.3.3
ply                              3.4
policycoreutils-default-encoding 0.1
pyasn1                           0.1.9
pycparser                        2.19
pycurl                           7.19.0
pygobject                        3.22.0
pygpgme                          0.3
pyliblzma                        0.5.3
PyNaCl                           1.3.0
python-dateutil                  1.5
python-linux-procfs              0.4.9
pyudev                           0.15
pyxattr                          0.5.1
PyYAML                           3.13
requests                         2.22.0
ruamel.ordereddict               0.4.14
ruamel.yaml                      0.16.5
ruamel.yaml.clib                 0.1.2
schedutils                       0.4
seobject                         0.1
sepolicy                         1.1
setuptools                       0.9.8
six                              1.12.0
slip                             0.4.0
slip.dbus                        0.4.0
SSSDConfig                       1.16.5
texttable                        0.9.1
urlgrabber                       3.10
urllib3                          1.25.3
websocket-client                 0.56.0
wheel                            0.33.4
yum-langpacks                    0.4.2
yum-metadata-parser              1.1.4

を取得し、問題の起きているマシンに pip2.lst として保存

vi pip2.lst

ansible                          2.9.16
ansible-lint                     4.1.0
ansible-tower-cli                3.3.6
asn1crypto                       0.24.0
Babel                            0.9.6
backports.ssl-match-hostname     3.7.0.1
bcrypt                           3.1.7
cached-property                  1.5.1
certifi                          2019.6.16
cffi                             1.12.3
chardet                          3.0.4
Click                            7.0
colorama                         0.4.1
configobj                        4.7.2
cryptography                     2.7
decorator                        3.4.0
docker                           4.0.2
docker-compose                   1.24.1
docker-pycreds                   0.4.0
dockerpty                        0.4.1
docopt                           0.6.2
enum34                           1.1.6
functools32                      3.2.3-2
httplib2                         0.18.1
idna                             2.8
iniparse                         0.4
ipaddress                        1.0.22
IPy                              0.75
Jinja2                           2.7.2
jmespath                         0.9.4
jsonschema                       2.6.0
kitchen                          1.1.1
langtable                        0.0.31
lmdb                             0.92
MarkupSafe                       0.11
paramiko                         2.6.0
passlib                          1.7.1
perf                             0.1
pip                              20.3.3
ply                              3.4
policycoreutils-default-encoding 0.1
pyasn1                           0.1.9
pycparser                        2.19
pycurl                           7.19.0
pygobject                        3.22.0
pygpgme                          0.3
pyliblzma                        0.5.3
PyNaCl                           1.3.0
python-dateutil                  1.5
python-linux-procfs              0.4.9
pyudev                           0.15
pyxattr                          0.5.1
PyYAML                           3.13
requests                         2.22.0
ruamel.ordereddict               0.4.14
ruamel.yaml                      0.16.5
ruamel.yaml.clib                 0.1.2
schedutils                       0.4
seobject                         0.1
sepolicy                         1.1
setuptools                       0.9.8
six                              1.12.0
slip                             0.4.0
slip.dbus                        0.4.0
SSSDConfig                       1.16.5
texttable                        0.9.1
urlgrabber                       3.10
urllib3                          1.25.3
websocket-client                 0.56.0
wheel                            0.33.4
yum-langpacks                    0.4.2
yum-metadata-parser              1.1.4
[esc]
:wq!

これを以下のコマンドで強制インストールしてみる

cat pip2.lst | awk '{print $1"=="$2}' | xargs pip2 install

いくつかのモジュールでバージョンが合わないものがあるが、その時はエラー内容に導入可能バージョンの羅列が表示されているので一番近いバージョン番号を控えて pip2.lst の右側に書かれているバージョンを適時微修正してインストールを進める

yum-langpacks のパッケージインストール

しばらく進めていくと

ERROR: Could not find a version that satisfies the requirement yum-langpacks==0.4.2 (from versions: none)
ERROR: No matching distribution found for yum-langpacks==0.4.2

と言われるので、これは真面目に入れておこう
No matching distribution found for yum-langpacks==0.4.2
と言っているので pip でのインストールではなくパッケージなのだろうと推測
CentOS のパッケージリストを探すとパッケージが存在するのでダウンロードしてインストール

wget https://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/yum-langpacks-0.4.2-7.el7.noarch.rpm
--2021-01-22 23:47:56--  https://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/yum-langpacks-0.4.2-7.el7.noarch.rpm
Resolving rpmfind.net (rpmfind.net)... 195.220.108.108
Connecting to rpmfind.net (rpmfind.net)|195.220.108.108|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 31312 (31K) [application/x-rpm]
Saving to: ‘yum-langpacks-0.4.2-7.el7.noarch.rpm’

100%[======================================>] 31,312       145KB/s   in 0.2s

2021-01-22 23:47:57 (145 KB/s) - ‘yum-langpacks-0.4.2-7.el7.noarch.rpm’ saved [31312/31312]

rpm -ivh yum-langpacks-0.4.2-7.el7.noarch.rpm
error: Failed dependencies:
	langtable-python is needed by yum-langpacks-0.4.2-7.el7.noarch

langtable-python が必要と言われるのでインストール

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/langtable-python-0.0.31.4.el7.noarch.rpm
--2021-01-22 23:50:46--  http://mirror.centos.org/centos/7/os/x86_64/Packages/langtable-python-0.0.31-4.el7.noarch.rpm
Resolving mirror.centos.org (mirror.centos.org)... 147.75.93.107, 2604:1380:3000:2800::1
Connecting to mirror.centos.org (mirror.centos.org)|147.75.93.107|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 28540 (28K) [application/x-rpm]
Saving to: ‘langtable-python-0.0.31-4.el7.noarch.rpm’

100%[======================================>] 28,540      --.-K/s   in 0.002s

2021-01-22 23:50:46 (11.0 MB/s) - ‘langtable-python-0.0.31-4.el7.noarch.rpm’ saved [28540/28540]

rpm -ivh langtable-python-0.0.31-4.el7.noarch.rpm
error: Failed dependencies:
	langtable = 0.0.31-4.el7 is needed by langtable-python-0.0.31-4.el7.noarch
	langtable-data = 0.0.31-4.el7 is needed by langtable-python-0.0.31-4.el7.noarch

langtable と langtable-data も必要らしいので落としてくる

rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/langtable-0.0.31-4.el7.noarch.rpm
Retrieving http://mirror.centos.org/centos/7/os/x86_64/Packages/langtable-0.0.31-4.el7.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:langtable-0.0.31-4.el7           ################################# [100%]

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/langtable-data-0.0.31-4.el7.noarch.rpm
--2021-01-22 23:53:24--  http://mirror.centos.org/centos/7/os/x86_64/Packages/langtable-data-0.0.31-4.el7.noarch.rpm
Resolving mirror.centos.org (mirror.centos.org)... 103.232.121.196, 2406:da1a:fcb:2f01:b6e2:c6:795:b503
Connecting to mirror.centos.org (mirror.centos.org)|103.232.121.196|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 634592 (620K) [application/x-rpm]
Saving to: ‘langtable-data-0.0.31-4.el7.noarch.rpm’

100%[======================================>] 634,592     2.49KB/s   in 3m 33s

2021-01-22 23:56:58 (2.91 KB/s) - ‘langtable-data-0.0.31-4.el7.noarch.rpm’ saved [634592/634592]

rpm -ivh langtable-data-0.0.31-4.el7.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:langtable-data-0.0.31-4.el7      ################################# [100%]

langtable-python をインストール

rpm -ivh langtable-python-0.0.31-4.el7.noarch.rpm.1
Preparing...                          ################################# [100%]
Updating / installing...
   1:langtable-python-0.0.31-4.el7    ################################# [100%]

yum-langpacks をインストール

rpm -ivh yum-langpacks-0.4.2-7.el7.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:yum-langpacks-0.4.2-7.el7        warning: /etc/yum/pluginconf.d/langpacks.conf created as /etc/yum/pluginconf.d/langpacks.conf.rpmnew
################################# [100%]

どうかな?

# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   cannot import name _bytes_repr

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

う〜ん、やっぱりパッケージだけじゃだめか
再度モジュールのインストール

cat pip2.lst | awk '{print $1"=="$2}' | xargs pip2 install

pyxattr でエラー

    xattr.c:25:24: fatal error: attr/xattr.h: No such file or directory
     #include <attr/xattr.h>
                            ^

ヘッダーファイルがない模様なのでパッケージを追加インストール

 wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libattr-devel-2.4.46-13.el7.x86_64.rpm
--2021-01-23 00:13:15--  http://mirror.centos.org/centos/7/os/x86_64/Packages/libattr-devel-2.4.46-13.el7.x86_64.rpm
Resolving mirror.centos.org (mirror.centos.org)... 147.75.93.107, 2604:1380:3000:2800::1
Connecting to mirror.centos.org (mirror.centos.org)|147.75.93.107|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35968 (35K) [application/x-rpm]
Saving to: ‘libattr-devel-2.4.46-13.el7.x86_64.rpm’

100%[======================================>] 35,968      --.-K/s   in 0.001s

2021-01-23 00:13:15 (23.1 MB/s) - ‘libattr-devel-2.4.46-13.el7.x86_64.rpm’ saved [35968/35968]

 rpm -ivh libattr-devel-2.4.46-13.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:libattr-devel-2.4.46-13.el7      ################################# [100%]

再度モジュールのインストール

 cat pip2.lst | awk '{print $1"=="$2}' | xargs pip2 install

全て更新完了

さて、結果は・・・・・・

# yum
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos,
              : subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

You need to give some command
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         Display, or use, the groups information
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages
install        Install a package or packages on your system
langavailable  Check available languages
langinfo       List languages information
langinstall    Install appropriate language packs for a language
langlist       List installed languages
langremove     Remove installed language packs for a language
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repo-pkgs      Treat a repo. as a group of packages, so we can install/remove all of them
repolist       Display the configured software repositories
search         Search package details for the given string
shell          Run an interactive yum shell
swap           Simple way to swap packages, instead of using shell
update         Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        Update packages taking obsoletes into account
version        Display a version for the machine and/or available repos.


Options:
  -h, --help            show this help message and exit
  -t, --tolerant        be tolerant of errors
  -C, --cacheonly       run entirely from system cache, don't update cache
  -c [config file], --config=[config file]
                        config file location
  -R [minutes], --randomwait=[minutes]
                        maximum command wait time
  -d [debug level], --debuglevel=[debug level]
                        debugging output level
  --showduplicates      show duplicates, in repos, in list/search commands
  -e [error level], --errorlevel=[error level]
                        error output level
  --rpmverbosity=[debug level name]
                        debugging output level for rpm
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  -y, --assumeyes       answer yes for all questions
  --assumeno            answer no for all questions
  --version             show Yum version and exit
  --installroot=[path]  set install root
  --enablerepo=[repo]   enable one or more repositories (wildcards allowed)
  --disablerepo=[repo]  disable one or more repositories (wildcards allowed)
  -x [package], --exclude=[package]
                        exclude package(s) by name or glob
  --disableexcludes=[repo]
                        disable exclude from main, for a repo or for
                        everything
  --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
  --obsoletes           enable obsoletes processing during updates
  --noplugins           disable Yum plugins
  --nogpgcheck          disable gpg signature checking
  --disableplugin=[plugin]
                        disable plugins by name
  --enableplugin=[plugin]
                        enable plugins by name
  --skip-broken         skip packages with depsolving problems
  --color=COLOR         control whether color is used
  --releasever=RELEASEVER
                        set value of $releasever in yum config and repo files
  --downloadonly        don't update, just download
  --downloaddir=DLDIR   specifies an alternate directory to store packages
  --setopt=SETOPTS      set arbitrary config and repo options
  --bugfix              Include bugfix relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs=BZS             Include packages needed to fix the given BZ, in
                        updates
  --cves=CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

  Plugin Options:

よし、復活!!!!

参考資料

yumコマンドを実行するとpycurlでエラーになる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?