Marsel.V
Marsel.V

Reputation: 1044

mysql workbench can't import pyodbc

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

Upvotes: 3

Views: 10506

Answers (6)

surly4shorty
surly4shorty

Reputation: 11

Update as of 11/4/2024: I was running into this issue on MySQL WorkBench v8.0.34.Instead of reinstalling python, I tried upgrading to the most recent version (v8.0.40) and it worked for me.

Upvotes: 1

Huckleberry
Huckleberry

Reputation: 61

I was having a similar issue and came across this question first in my searching. However, the following question and answer is what finally solved my problem: Issue while starting migration wizard in mysql workbench

I downgraded MySQL Workbench to 8.0.20 and pyodbc error was gone!

There are additional steps (as per above link) you can take to copy off the necessary files and upgrade again:

  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"

Upvotes: 1

Chris Smith
Chris Smith

Reputation: 688

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.

Upvotes: 2

rosh
rosh

Reputation: 35

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

Upvotes: 1

Flo
Flo

Reputation: 499

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.

Upvotes: 6

Marsel.V
Marsel.V

Reputation: 1044

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

Upvotes: 2

Related Questions