ImportError: No localization support for language 'eng' in python

Question:

I am getting ImportError: No localization support for language 'eng' when using MySQL Connector in Python.
My Traceback is as below.

Traceback (most recent call last):
  File "DB_Module.py", line 151, in QueryDatabase
  File "\shareappModulesmysqlconnector__init__.py", line 44, in Connect
  File "\shareappModulesmysqlconnectorconnection.py", line 106, in __init__
  File "\shareappModulesmysqlconnectorconnection.py", line 325, in connect
  File "\shareappModulesmysqlconnectorconnection.py", line 288, in _open_connection
  File "\shareappModulesmysqlconnectornetwork.py", line 326, in open_connection
  File "\sfsshow_timeShowtime_PackageshowtimeModulesmysqlconnectorerrors.py", line 160, in __init__
  File "\shareappModulesmysqlconnectorlocales__init__.py", line 52, in get_client_error
ImportError: No localization support for language 'eng'

And my Current used SQL is

SELECT * FROM systemdetails 
WHERE System_ID = 'System1' LIMIT 1

Can anyone tell me how to fix this error?

Asked By: Rao

||

Answers:

In order for the MySql connector to print the actual error string – it needs the eng/client_error file in the “locales” dir.

I personally, just manually created the dir “eng” and copy-paste the file from this link:
http://pydoc.net/Python/mysql-connector-python/1.0.7/mysql.connector.locales.eng.client_error/

> mkdir eng
> touch eng/__init__.py
> vi eng/client_error.py
> ... copy-paste, save, and exit.

I run the code again, and received:

2013: Lost connection to MySQL server during query

You’ll probably get a different error, but hope it helps.

Answered By: Ricky Levi

Just put this to import the locale when you compile again with pyInstaller or py2exe.

from mysql.connector.locales.eng import client_error

They will include the modules needed to fix the error.

Answered By: lloydyu24

In my case, changing the latest mysql.connector module to a former version solved the problem. I changed the version from 8.0.30 to 8.0.17.

Answered By: Akhil Raj