1

I'm attempting to do the mysql tutorial for the python connector.

Using Xubuntu 14.04, python3, mysql 5.5.35, eclipse Luna and pydev 3.6.0. I installed the python.connector via instructions on the mysql website.

When I use python 3 from the command line into the interactive shell, I can do

import mysql.connector

just fine. I can then proceed to do things with that import, for example all the following code runs fine:

>>> import mysql.connector
>>> cnx = mysql.connector.connect(user='root', password='root', host='127.0.0.1',database='testdb')
>>> cnx.close()

In eclipse, I am unable to import it properly, but I still have a red 'squiggly' with unresolved import errors. As such I'm unable to use autocomplete for any of my script. . I've set up my interpreter to use python3 (as well as the python 3.4 option, tried separately).

On the left, I can see mysql under python > System Libs > python3/dist-packages > mysql as part of my project

enter image description here

enter image description here

My interpreter is set up as such:

enter image description here

Regardless of what I do, I am unable to get it to import in eclipse. I've tried the answers here to no avail:

https://stackoverflow.com/a/3864323/3665278

How do I handle an UnresolvedImport Eclipse (Python)

https://stackoverflow.com/q/27897035

Community
  • 1
  • 1
Mitch
  • 1,604
  • 4
  • 20
  • 36

1 Answers1

2

I had a similar problem on Mac OS X and found that the python connector binary install did not work. Instead, I installed the 'Platform Independent' TAR from

http://dev.mysql.com/downloads/connector/python/ 

and ran

sudo python setup.py install 

as instructed. This put the connector code into the site-packages and then

import mysql.connector

started working.

Bob Swerdlow
  • 542
  • 7
  • 7
  • This worked for me on Windows 10 64 bit. I first checked if 32 or 64 bit python installed and used appropriate .msi which in my case was 32. – Jeff Albrecht May 04 '16 at 11:46