Unable to resolve the name 'py.anything' when using Homebrew Python
28 ビュー (過去 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?
Julien Montant 2022 年 10 月 24 日
I have exactly the same issue with macports' python3.9. However, the Matlab-python binding works indeed with the "native" (command line tools) macos python3 (3.9).
What I don't understand is that if it's related with the ARM native linking, the native macOS python shouldn't work neither right?
(Waiting for the R2022b ARM compatible beta to come out, let's see how it goes...)
回答 (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 firstname.lastname@example.org
After installation, i ran
axbrew unlink email@example.com
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/Cellarfirstname.lastname@example.org/3.9.15/bin
You can use that pip3.9 to install numpy and other packages.
Then in matlab:
Find more on Call Python from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!