Bug #88376 ImportError: No module named utilities.common.tools ; Unable to use mysqlfrm
Submitted: 6 Nov 2017 20:19 Modified: 8 Nov 2017 10:20
Reporter: Shahriyar Rzayev Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Utilities Severity:S2 (Serious)
Version:1.6.5-1 OS:CentOS (7)
Assigned to: CPU Architecture:Any

[6 Nov 2017 20:19] Shahriyar Rzayev
Description:
Hi,
I got the .rpm from here:

https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.6.5-1.el7.noarch.rpm

And installed it on CentOS 7.

The result:
$ mysqlfrm
Traceback (most recent call last):
  File "/usr/bin/mysqlfrm", line 27, in <module>
    from mysql.utilities.common.tools import (check_python_version,
ImportError: No module named utilities.common.tools

How to repeat:
See description.
[6 Nov 2017 20:53] MySQL Verification Team
miguel@tikal:~/Downloads $ sudo yum install mysql-utilities-1.6.5-1.el7.noarch.rpm 
Loaded plugins: fastestmirror, langpacks
Examining mysql-utilities-1.6.5-1.el7.noarch.rpm: mysql-utilities-1.6.5-1.el7.noarch
Marking mysql-utilities-1.6.5-1.el7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-utilities.noarch 0:1.6.5-1.el7 will be installed
--> Processing Dependency: mysql-connector-python >= 2.0.0 for package: mysql-utilities-1.6.5-1.el7.noarch
base                                                                                                                                | 3.6 kB  00:00:00     
epel/x86_64/metalink                                                                                                                | 3.4 kB  00:00:00     
extras                                                                                                                              | 3.4 kB  00:00:00     
google-chrome                                                                                                                       |  951 B  00:00:00     
mysql-connectors-community                                                                                                          | 2.5 kB  00:00:00     
mysql-tools-community                                                                                                               | 2.5 kB  00:00:00     
mysql57-community                                                                                                                   | 2.5 kB  00:00:00     
nux-dextop                                                                                                                          | 2.9 kB  00:00:00     
updates                                                                                                                             | 3.4 kB  00:00:00     
google-chrome/primary                                                                                                               | 2.0 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: linorg.usp.br
 * epel: mirror.uta.edu.ec
 * extras: ftp.unicamp.br
 * nux-dextop: mirror.li.nux.ro
 * updates: ftp.unicamp.br
google-chrome                                                                                                                                          3/3
--> Running transaction check
---> Package mysql-connector-python.x86_64 0:2.1.7-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                                 Arch                    Version                        Repository                                            Size
===========================================================================================================================================================
Installing:
 mysql-utilities                         noarch                  1.6.5-1.el7                    /mysql-utilities-1.6.5-1.el7.noarch                  3.5 M
Installing for dependencies:
 mysql-connector-python                  x86_64                  2.1.7-1.el7                    mysql-connectors-community                           241 k

Transaction Summary
===========================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total size: 3.7 M
Total download size: 241 k
Installed size: 4.6 M
Is this ok [y/d/N]: y
Downloading packages:
mysql-connector-python-2.1.7-1.el7.x86_64.rpm                                                                                       | 241 kB  00:00:01  
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-connector-python-2.1.7-1.el7.x86_64                                                                                               1
  Installing : mysql-utilities-1.6.5-1.el7.noarch                                                                                                      2
  Verifying  : mysql-utilities-1.6.5-1.el7.noarch                                                                                                      1
  Verifying  : mysql-connector-python-2.1.7-1.el7.x86_64                                                                                               2

Installed:
  mysql-utilities.noarch 0:1.6.5-1.el7                                                                                                                  

Dependency Installed:
  mysql-connector-python.x86_64 0:2.1.7-1.el7                                                                                                           

Complete!
miguel@tikal:~/Downloads $ mysqlfrm 
Usage: mysqlfrm --server=[user[:<pass>]@host[:<port>][:<socket>]|<login-path>[:<port>][:<socket>]] [path\tbl1.frm|db:tbl.frm]

mysqlfrm: error: Nothing to do. You must specify a list of paths or files to read. See --help for more information and examples.
miguel@tikal:~/Downloads $ 
miguel@tikal:~/Downloads $ lsb_release -d
Description:    CentOS Linux release 7.4.1708 (Core)
[6 Nov 2017 21:21] Shahriyar Rzayev
For me the mysql-connector-python version is:

$ rpm -qa | grep mysql-connector
mysql-connector-python-8.0.4-0.1.dmr.el7.x86_64

Which I installed before.

And during installation of mysql-utilities there was no conflict or error based on version of connector.
[7 Nov 2017 14:36] Shahriyar Rzayev
Confirming that it is due to mysql-connector version:

$ sudo yum install mysql-connector-python-2.1.7-1.el7.x86_64.rpm 
Loaded plugins: auto-update-debuginfo, fastestmirror
Examining mysql-connector-python-2.1.7-1.el7.x86_64.rpm: mysql-connector-python-2.1.7-1.el7.x86_64
Marking mysql-connector-python-2.1.7-1.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-connector-python.x86_64 0:2.1.7-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

$ sudo yum install mysql-utilities-1.6.5-1.el7.noarch.rpm
Loaded plugins: auto-update-debuginfo, fastestmirror
Examining mysql-utilities-1.6.5-1.el7.noarch.rpm: mysql-utilities-1.6.5-1.el7.noarch
Marking mysql-utilities-1.6.5-1.el7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-utilities.noarch 0:1.6.5-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

$ mysqlfrm
Usage: mysqlfrm --server=[user[:<pass>]@host[:<port>][:<socket>]|<login-path>[:<port>][:<socket>]] [path\tbl1.frm|db:tbl.frm]

mysqlfrm: error: Nothing to do. You must specify a list of paths or files to read. See --help for more information and examples.
[8 Nov 2017 10:20] MySQL Verification Team
Thank you for the feedback.

[root@CentOS7 ushastry]# rpm -qa|grep mysql
mysql-community-libs-compat-8.0.3-0.1.rc.el7.x86_64
mysql-community-common-8.0.3-0.1.rc.el7.x86_64
mysql57-community-release-el7-11.noarch
mysql-connector-python-8.0.4-0.1.dmr.el7.x86_64
mysql-community-server-8.0.3-0.1.rc.el7.x86_64
mysql-community-libs-8.0.3-0.1.rc.el7.x86_64
mysql-shell-8.0.0-0.1.dmr.el7.x86_64
mysql-community-client-8.0.3-0.1.rc.el7.x86_64
[root@CentOS7 ushastry]# python
Python 2.7.5 (default, Aug  4 2017, 00:39:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>> 
[root@CentOS7 ushastry]# yum install mysql-community-utilities
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos-distro.cavecreek.net
 * extras: centos.aol.com
 * updates: centos.mirrors.tds.net
No package mysql-community-utilities available.
Error: Nothing to do
[root@CentOS7 ushastry]# yum install mysql-utilities
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos-distro.cavecreek.net
 * extras: centos.aol.com
 * updates: centos.mirrors.tds.net
Resolving Dependencies
--> Running transaction check
---> Package mysql-utilities.noarch 0:1.6.5-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================
 Package                                     Arch                               Version                                 Repository                                         Size
================================================================================================================================================================================
Installing:
 mysql-utilities                             noarch                             1.6.5-1.el7                             mysql-tools-community                             836 k

Transaction Summary
================================================================================================================================================================================
Install  1 Package

Total download size: 836 k
Installed size: 3.5 M
Is this ok [y/d/N]: y
Downloading packages:
mysql-utilities-1.6.5-1.el7.noarch.rpm                                                                                                                   | 836 kB  00:00:16     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-utilities-1.6.5-1.el7.noarch                                                                                                                           1/1 
  Verifying  : mysql-utilities-1.6.5-1.el7.noarch                                                                                                                           1/1 

Installed:
  mysql-utilities.noarch 0:1.6.5-1.el7                                                                                                                                          

Complete!
[root@CentOS7 ushastry]# mysqlfrm 
Traceback (most recent call last):
  File "/bin/mysqlfrm", line 27, in <module>
    from mysql.utilities.common.tools import (check_python_version,
ImportError: No module named utilities.common.tools
[root@CentOS7 ushastry]#
[25 Apr 2018 21:56] Robert Jacob
This seems to be an architecture problem:

When the python connector is not installed (before the utilities), then the dependency is resolved to the 64bit version:

[root@db2-au ~]# yum install mysql-utilities
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package mysql-utilities.noarch 0:1.6.5-1.el7 will be installed
--> Processing Dependency: mysql-connector-python >= 2.0.0 for package: mysql-utilities-1.6.5-1.el7.noarch
--> Running transaction check
---> Package mysql-connector-python.x86_64 0:8.0.11-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================================================================
 Package                                                        Arch                                           Version                                              Repository                                                          Size
=============================================================================================================================================================================================================================================
Installing:
 mysql-utilities                                                noarch                                         1.6.5-1.el7                                          mysql-tools-community                                              836 k
Installing for dependencies:
 mysql-connector-python                                         x86_64                                         8.0.11-1.el7                                         mysql-connectors-community                                         418 k

Transaction Summary
=============================================================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 1.2 M

The connector installs packages into /usr/lib64/python whereas the utilities put it into /usr/lib/python.

There is 1 solution and 1 workaround:
Solution: manually install the mysql-connector-python.noarch before the utilities. This installs an older version 2.0.4-1.el7 on my system

Workaround:
ln -s /usr/lib/python2.7/site-packages/mysql/utilities /usr/lib64/python2.7/site-packages/mysql/utilities
[25 Apr 2018 22:22] Robert Jacob
Small correction to previous comment. The solution isn't quite working. The old version of the connector doesn't know about the new password encryptions in version 8 of MySQL. I had to revert to the symlink workaround instead and use the newer python connector
[13 Jul 2018 7:12] MySQL Verification Team
Bug #90682 marked as duplicate of this one
[15 Jun 2019 7:11] Reio Remma
Using mysqldbcompare with the default mysql-connector-python 8.0.16-1.el7 from @mysql-connectors-community still ends with the error:

Sat Jun 15 06:55:48 UTC 2019
Traceback (most recent call last):
  File "/usr/bin/mysqldbcompare", line 28, in <module>
    from mysql.utilities.common.tools import check_python_version
ImportError: No module named utilities.common.tools

I can confirm that the following fixed the issue for me as well:

ln -s /usr/lib/python2.7/site-packages/mysql/utilities /usr/lib64/python2.7/site-packages/mysql/utilities