Bug #101610 Migration not finding pyodbc module
Submitted: 13 Nov 2020 21:03 Modified: 14 Dec 2020 15:09
Reporter: Carl Carstenson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Migration Severity:S1 (Critical)
Version:8.0.22 OS:Linux (Ubuntu 20.04.1 LTS)
Assigned to: CPU Architecture:Any
Tags: pyodbc

[13 Nov 2020 21:03] Carl Carstenson
Description:
When going into migration I get the warning "Could not import the pyodbc python module. You need pyodbc 2.1.8 or newer for migrations from RDBMSes other than MySQL.". This happens due to python not finding the pyodbc module. I don't find any way of installing pyodbc for python2.7. It seems to only work with python3. That being said, it appears that WB only works with python2. If I continue to try and use Generic RDBMS, it fails when I select "ODBC Data Source" as the connection method and the log contains:

12:52:02 [ERR][         python]: error calling DbGenericRE.getDataSourceNamesTraceback (most recent call last):
12:52:02 [ERR][         python]:   File "/usr/lib/mysql-workbench/modules/db_generic_re_grt.py", line 673, in getDataSourceNames
12:52:02 [ERR][         python]:     return GenericReverseEngineering.getDataSourceNames()
12:52:02 [ERR][         python]:   File "/usr/lib/mysql-workbench/modules/db_generic_re_grt.py", line 93, in getDataSourceNames
12:52:02 [ERR][         python]:     import pyodbc
12:52:02 [ERR][         python]: ImportError: No module named pyodbc
12:52:02 [ERR][ DbConnectPanel]: Error calling get_enum_options() for param dsn: error calling Python module function DbGenericRE.getDataSourceNamesSaved connection list (MySQL: 1)

I cannot find any workaround for getting pyodbc to load. I have installed WB from mysql-workbench-community_8.0.22-1ubuntu20.04_amd64.deb and also from snap's mysql-workbench-community from tonybolzan. They both have the same error.

How to repeat:
In WB, go to Start Migration. A pop-up message appears: Could not import the pyodbc python module. You need pyodbc 2.1.8 or newer for migrations from RDBMSes other than MySQL.

Suggested fix:
I'm not the expert, but upgrading migration to use python3 would be one obvious solution. I cannot find any other means for getting past this seemingly dependency issue.
[13 Nov 2020 22:58] Carl Carstenson
Somehow, I was finally able to get pyodbc installed in my python2.7. Closing this due to it appearing to be a PEBCAK.
[13 Dec 2020 8:47] Shivan Kamal
Hey Carl,

Are you able to share how you were able to succesfully install python2.7?

I did this as well but It still did not work for me.

I managed to fix this by removing Workbench 8.0.22 and installing 8.0.20, which worked!

However according to an answer on stackoverflow: https://stackoverflow.com/questions/64679366/issue-while-starting-migration-wizard-in-mysq...

The following can be done to resolve it if installing python2.7 doesn't work:

1. Try to install MySQL Workbench with lower version, e.g. 8.0.20. (It's easy with MySql Installer)
2. Find file "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\python\site-packages\pyodbc.pyd" and save it.
3. Then upgrade MySQL Workbench to the latest (in my case 8.0.22)
4. Copy previously saved file pyodbc.pyd back to the "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\python\site-packages
[14 Dec 2020 15:09] Carl Carstenson
Shivan,

I'm afraid I'm not going to be much help for you. I'm not sure how I ended up either getting pyodbc to work with python2 or getting WB to work with python3. I also don't know if there is any relation with my problem in Linux and your Windows issue. I had other issues with my ODBC driver and finally dropped WB in favor of writing my own migration script in Perl and coming out so much better in the end.

My current system doesn't have python2 installed, but pyodbc does load in python3. But again, I'm not using WB nor do I have a need for python. Good luck.