mysql workbench can't import pyodbc

Viewed 4436

I have installed mysql workbench v. 8.0.13, and am trying to run the migration tool, but I get an error:

Could not import the pyodbc python module. You need pyodbc 2.1.8 or newer for migrations from RDBMSes other than MySQL.

I have installed pyodbc:

Python 3.7.0 (default, Sep 28 2018, 16:44:32) 
[GCC 8.2.1 20180831] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> pyodbc.version
'4.0.24'

How can I fix this problem?

OS: Linux my-pc 4.19.0-3-MANJARO #1 SMP PREEMPT Sat Oct 27 22:40:22 UTC 2018 x86_64 GNU/Linux
4 Answers

I faced the same problem on Windows and replacing python 3.8 install with a 2.7 one wasn't enough.

That was very weird because when I launched a python console, I was able to import pyodbc module. But when I launched the python.exe that is included in Mysql Workbench installation directory, the module couldn't be loaded (an error was telling that a dll couldn't be find, without telling which one).

I first thought this was related to a sys.path difference between these two contexts, but the loading error persisted after having make the paths identical.

Finally I found a python27.dll file in the Mysql Workbench directory, and renaming this file to python27.notdll (to prevent if from being loaded) solved the pyodbc loading problem.

I don't know what could be the side effects of this dll disabling, but as far as python 2.7 is already installed and works, I don't think this should be a problem.

Anyway, the migration wizard is now working.

it was necessary to install python version 2.7 and pyodbc for it

In my situation I was trying to use SQL WorkBench's database migration wizard to migrate SQL Server tables to MySQL and ran into this pyodbc error.

Building onto @Flo answer above for Windows 10:

  1. Uninstall all python installations (this step may be optional but I had many installs and wanted to work from a clean slate)
  2. install python 2.7.x 64-bit. During the installation, register the python.exe to the $Path/command line (this was un-checked by default so I had to enable it).
  3. Install MySQL WorkBench 64-bit (see under the "Other Downloads" section, v8.0.22 in my case)
  4. Install MS VC++ Compiler for Python (as referenced here to solve the "Error: INCLUDE Environment Variable is empty" error)
  5. Open cmd.exe (command line) and type: cd C:\Python27\Scripts
  6. run pip command: pip install -Iv pyodbc==2.1.8
  7. Rename the Sql WorkBench's copy of python27.dll to python27.nodll under "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\
  8. Start SQL WorkBench > Database menu > Migration Wizard > click "Start Migration" button and the pyodbc error should no longer show.

I faced the same issue with MySQL Workbench v. 8.0.22. Resolved it by installing Python2.7 and renaming the python27.ddl to force the MySQL Workbench to use it from python installation

Related