Symlink Python

The issue appear when I tried to build modmesh on my new Mac, abnormal behavior appeared in python version.

Issue

Before installing dependency, we designate our python version to be 3.10:

1
brew link python3@10

and with install all our dependencies via

1
pip3.10 install (package)

Yet as we later run our target viewer, we get

1
2
3
dyld[7349]: Library not loaded: @rpath/Python3.framework/Versions/3.9/Python3
Referenced from: <E444B955-70C8-30A3-81A5-76967E9CCB70> /Users/en/Code/modmesh/build/dev39/cpp/binary/viewer/viewer.app/Contents/MacOS/viewer
Reason: tried: '/Users/en/Library/Python/3.9/lib/python/site-packages/PySide6/Python3.framework/Versions/3.9/Python3' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/en/Library/Python/3.9/lib/python/site-packages/PySide6/Python3.framework/Versions/3.9/Python3' (no such file),

Error log hinted some of the environment variables have been set to be python3.9 which is inconsistant with our designation.

clue

1
2
3
4
modmesh % python3 --version
Python 3.9.6
modmesh % which python3
/usr/bin/python3

Solution

Python on Mac by default link to the python on the operating system, which located at /usr/bin/python3, yet our dependencies are all installed by python 3.10 and can be found under /opt/homebrew/lib/python3.10, therefore installed dependencies cannot found.

To solve this problem, we should link the python to python 3.10 installed by brew:

1
ln -s /opt/homebrew/bin/python3.10 python3

and problem solved.