Process record of installing maven from yum

Install maven, environment virtual machine:

1. Install yum configuration tool

$ yum install -y yum-utils

2. Use the configuration tool to configure the third-party epel source warehouse

[root@ab0be27c0bd3 ~]# yum-config-manager --add-repo

Traceback (most recent call last):
  File "/usr/bin/yum-config-manager", line 6, in <module>
    import yum
ImportError: No module named yum

Perform this step to report an error

Traceback (most recent call last):
  File "/usr/bin/yum-config-manager", line 6, in <module>
    import yum
ImportError: No module named yum

To view a file based on an error:

[root@ab0be27c0bd3 ~]# cat /usr/bin/yum-config-manager | head -n 10

#!/usr/bin/python -tt

import os, os.path
import sys
import re
import yum
from utils import YumUtilBase
import logging
import fnmatch

It is said that the yum module cannot be found, but the yum command can be used normally. Baidu said that the version does not match. Yum was written in python

View the version of python

[root@ab0be27c0bd3 ~]# whereis python

python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python2.7-config /usr/bin/python2.6 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/local/bin/python /usr/local/bin/python2.7 /usr/local/bin/python2.7-config /usr/local/lib/python2.7 /usr/include/python2.7 /usr/share/man/man1/python.1.gz
[root@ab0be27c0bd3 ~]#
[root@ab0be27c0bd3 ~]#
[root@ab0be27c0bd3 ~]# python -V
Python 2.7.9

You can see that there are multiple versions. The version in use is 2.7.9

Take a look at the version yum uses

[root@ab0be27c0bd3 ~]# cat /usr/bin/yum

import sys
    import yum
except ImportError:
    print >> sys.stderr, """\

In fact, I can't see. Let's look at python's soft connection:

[root@ab0be27c0bd3 ~]# ls -il /usr/bin | grep python
33555577 -rwxr-xr-x   1 root  root       11216 Dec  1  2015 abrt-action-analyze-python
34184332 lrwxrwxrwx   1 root  root          24 Jul 19  2019 python -> /usr/local/bin/python2.7
33827326 lrwxrwxrwx   1 root  root           9 Nov 22  2016 python2 -> python2.7
34184333 lrwxrwxrwx   1 root  root           7 Nov 22  2016 python2.6 -> python2
33827328 -rwxr-xr-x   1 root  root        7136 Nov 20  2015 python2.7
33827329 -rwxr-xr-x   1 root  root        1835 Nov 20  2015 python2.7-config
33827327 lrwxrwxrwx   1 root  root          16 Nov 22  2016 python2-config -> python2.7-config
33827325 lrwxrwxrwx   1 root  root          14 Nov 22  2016 python-config -> python2-config

Actually, I don't understand this. In my opinion, python, python2 and python2.6 all point to python2.7, so the version used by / usr/bin/yum and / usr/bin/yum config manager should be the same, but the result is an error. According to Baidu, change / usr/bin/yum config manager to 2.6

#!/usr/bin/python2.6 -tt

If you execute the command again, you will not report the error + | + |, but report the following error:

Loaded plugins: fastestmirror, langpacks
adding repo from:
grabbing file to /etc/yum.repos.d/epel-apache-maven.repo
Could not fetch/save url to file /etc/yum.repos.d/epel-apache-maven.repo: [Errno 14] curl#7 - "Failed connect to; Connection refused"

Because I execute on the virtual machine and can't connect to the external network, I need to open the external network (the tool of the company that I use directly, just click to open the external network, how to open the external network for the virtual machine hasn't been studied yet). After opening the external network, this command is executed successfully.

3. Enable warehouse

[root@ab0be27c0bd3 ~]# yum-config-manager --enable epel-apache-maven

Loaded plugins: fastestmirror, langpacks
============================================================================== repo: epel-apache-maven ==============================================================================
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl =

4. Install maven

[root@ab0be27c0bd3 ~]# yum install -y apache-maven

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

   No module named yum

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.9 (default, Jul 19 2019, 14:45:37)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

If you cannot solve this problem yourself, please go to
the yum faq at:

? Version mismatch?

Then change / usr/bin/yum to 2.6

import sys

Not to mention the version is inconsistent, but goose

[root@ab0be27c0bd3 ~]# yum install -y apache-maven

Loaded plugins: fastestmirror, langpacks

#! /usr/bin/python-ext-down
base                                                                                                                                                          | 3.6 kB  00:00:00
didi_jenkins_enable                                                                                                                                           | 1.5 kB  00:00:00
didi_op_toa_enable                                                                                                                                            | 1.5 kB  00:00:00
didi_txjenkins_enable                                                                                                                                         | 1.5 kB  00:00:00
epel                                                                                                                                                          | 5.3 kB  00:00:00
epel-apache-maven                                                                                                                                             | 3.3 kB  00:00:00
extras                                                                                                                                                        | 3.4 kB  00:00:00
updates                                                                                                                                                       | 3.4 kB  00:00:00
Traceback (most recent call last):
  File "/usr/libexec/urlgrabber-ext-down", line 22, in <module>
    from urlgrabber.grabber import \
ImportError: No module named urlgrabber.grabber

Exiting on user cancel

Then vim / usr / libexec / urlgrabber ext down

Change your head to

#! /usr/bin/python-ext-down

After printing a bunch of things, I don't know if it succeeds. I used the command MVN version to say that the command could not be found

Finally, there is another way:

# wget
# tar -zxvf apache-maven-3.5.4-bin.tar.gz
//Configure maven
# vim /etc/profile
export MAVEN_HOME=~/apache-maven-3.5.4 
//Make configuration effective
# source /etc/profile

Black question mark, use this maven anyway

Finally, maven is well done, and then the start-up project is built, and errors are reported when the project is built:

The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

Baidu solution, go to my maven installation directory to modify the startup file:

# vim ~/apache-maven-3.5.4/bin/mvn


build again and don't report that mistake

Tags: Programming yum Maven Apache Python

Posted on Mon, 16 Mar 2020 07:56:38 -0400 by reinmedia