How to add a path to the system path in MySQL Workbench for Mac (Big Sur)

Question:

I was using Catalina OS with MySQL Workbench for Mac, which worked fine for old iMac of mine. But when I recently bought a new Mac with Big Sur OS and installed MySQL Workbench, it gave me the follow import error:

Fatal Python error: initfsencoding: unable to load the file system codec, sys.path = ['/Applications/MySQLWorkbench.app/Contents/Resources/libraries', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload']
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000000011ac12e00 (most recent call first):

I knew that this was due to system path improperly configured as my python version is 3.8. So I added a path to the system path in bash_profile. See below:

export PYTHONPATH=~/Library/Python/3.8/lib/python/site-packages:$PYTHONPATH

export PATH=/usr/bin:$PATH

The resulting sys.path in python shell gave me this:

Python 3.8.2 (default, Nov  4 2020, 21:23:28) 
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python38.zip', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/lib-dynload', '/Users/phillipkim/Library/Python/3.8/lib/python/site-packages', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages']

I sourced the file and restarted the computer. However, I get the same error message when I try to run MySQL Workbench. I found the following website that explains where to update the system environment for MySQL Workbench, but it only shows examples for Windows and Linux OSs. How do I add a path to the system path for MySQL Workbench for Mac? Much appreciated.

Asked By: Phillip1982

||

Answers:

I found the following solution: https://bugs.mysql.com/bug.php?id=102364

MySQLWorkbench need Python3.7 Framework in /Library/Frameworks/

  1. Run brew install [email protected]
  2. Then, run sudo cp -r /usr/local/Cellar/[email protected]/3.7.9_3/Frameworks/Python.framework /Library/Frameworks/Python.framework
  3. Finally, open MySQLWorkbench and it works.

Or you can just create a symlink to the entire file (thx to @Phillip1982)

sudo ln -s /usr/local/Cellar/[email protected]/3.7.10_1/Frameworks/Python.framework /Library/Frameworks/Python.framework

Answered By: Dalister

Problem

enter image description here

Termination Reason: Namespace DYLD, 
Code 1 Library missing Library not loaded: 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Python' 
Referenced from: '/Applications/MySQLWorkbench.app/Contents/MacOS/MySQLWorkbench' 
Reason: tried: '/System/Library/Frameworks/Python.framework/Versions/2.7/Python'

Solution

The method explained over here worked well for me. So the issue is that python 2.7 got removed from Mac 12.3, which affects applications like Workbench.

To make them work again, you need to download Python 2.7.x from official download link. Then install it and your tool should begin to operate.

Answered By: Imran Zahoor

I got the same issue after upgrading my macOS to Ventura. I had fixed this error simply by downloading the latest MYSQLWORKBENCH application and re-installing on my laptop

Answered By: Sushil Adhikari