Unable to resolve the name 'py.anything' when using Homebrew Python
19 ビュー (過去 30 日間)
I'm on an Apple Silicon mac, and the default python3 that Matlab finds (in /Library/Developer/CommandLineTools/usr/bin/python3, found with the setting pyenv('Version', 'python3')) is problematic because its pip can't seem to install numpy. The version that comes with Homebrew can build everything just fine, so I tried
PythonEnvironment with properties:
but now, I can't access anything through py: it just says "Unable to resolve the name", making it unusable.
Unable to resolve the name 'py.None'.
Any ideas on why this is, or how to work around it? Perhaps something like the homebrew Python is ARM-native code (I don't know if that's the case though), and there's some kind of linking issue because Matlab is on Rosetta?
回答 (2 件)
Al Danial 2022 年 7 月 27 日
I won't have a macOS machine handy for a while so I can't experiment. I imagine the MathWorks tech support would know... unless this level of fiddling falls outside the realm of what users ought to be doing.
Nate 2022 年 10 月 12 日
I ran into this same issue this morning. After a lot of trial and error, here is a solution that worked for me:
First, you need to have a second version of homebrew for installing intel-based apps: https://medium.com/mkdir-awesome/how-to-install-x86-64-homebrew-packages-on-apple-m1-macbook-54ba295230f
If you follow those instructions, you'll get to a point where you have added these lines to your .zsh profile:
export PATH=$HOME/bin:/usr/local/bin:$PATH# for intel x86_64 brew
alias axbrew='arch -x86_64 /usr/local/homebrew/bin/brew'
You can then use axbrew to install the x86_64 version of python3.9:
axbrew install email@example.com
After installation, i ran
axbrew unlink firstname.lastname@example.org
to be sure this version wasn't going to be accidently called by other programs
You should now have x86_64 versions of pip3.9 and python3.9 executables in: /usr/local/homebrew/Cellaremail@example.com/3.9.15/bin
You can use that pip3.9 to install numpy and other packages.
Then in matlab: