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 | dyld[7349]: Library not loaded: @rpath/Python3.framework/Versions/3.9/Python3 |
Error log hinted some of the environment variables have been set to be python3.9 which is inconsistant with our designation.
clue
1 | modmesh % python3 --version |
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.