Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS X Sierra: Can't make the magic commands work #258

Open
gacek91 opened this issue May 21, 2018 · 8 comments
Open

OS X Sierra: Can't make the magic commands work #258

gacek91 opened this issue May 21, 2018 · 8 comments

Comments

@gacek91
Copy link

gacek91 commented May 21, 2018

Hey there,

I'm pretty much out of ideas how to fix my issue.

This code works like a charm, no problems whatsoever.

from pymatbridge import Matlab
mlab = Matlab(executable='/Applications/MATLAB_R2018a.app/bin/matlab')
mlab.start()

However, I would really like to be able to use magic codes. Both codes below give me this error: ValueError: MATLAB failed to start

%load_ext pymatbridge
import pymatbridge as pymat
ip = get_ipython()
pymat.load_ipython_extension(ip)

I even tried changing MATLAB_BIN=/Applications/MATLAB_R2018a.app/bin/ in .../messenger/mexmaci/local.cfg, didn't help either.

Last but not least - I tried changing dir to .../messenger/ and running python3.6 make.py matlab. Got an error:

macbook-air:messenger Gacek$ python3.6 make.py matlab
Building messenger.mexmaci64...
/Applications/MATLAB_R2018a.app/bin/mex -O -L. -I. -lzmq ./src/messenger.c
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymatbridge/messenger/./src/messenger.c not found; check that you are in the correct current folder, and check the spelling of '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymatbridge/messenger/./src/messenger.c'.
Traceback (most recent call last):
  File "make.py", line 285, in <module>
    build_matlab(static=args.static)
  File "make.py", line 270, in build_matlab
    do_build(make_cmd, 'messenger.%s' % extension)
  File "make.py", line 178, in do_build
    subprocess.check_output(shlex.split(make_cmd), shell=use_shell)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/Applications/MATLAB_R2018a.app/bin/mex', '-O', '-L.', '-I.', '-lzmq', './src/messenger.c']' returned non-zero exit status 255.

Would be grateful for any ideas!

Regards,

Matt

@arokem
Copy link
Owner

arokem commented May 21, 2018

Maybe add an alias to your shell configuration?

alias matlab = "/Applications/MATLAB_R2018a.app/bin/matlab"

@gacek91
Copy link
Author

gacek91 commented May 22, 2018

No luck either. Is there any way to combine it all together and custom matlab path (like below) with pymatbridge.load_ipython_extension()?

from pymatbridge import Matlab
mlab = Matlab(executable='/Applications/MATLAB_R2018a.app/bin/matlab')

@arokem
Copy link
Owner

arokem commented May 22, 2018

I believe this should work:

pymatbridge.load_ipython_extension(executable='/Applications/MATLAB_R2018a.app/bin/matlab')

Doesn't it?

@arokem
Copy link
Owner

arokem commented May 22, 2018

Sorry, I mean:

pymatbridge.load_ipython_extension(ip, executable='/Applications/MATLAB_R2018a.app/bin/matlab')

@gacek91
Copy link
Author

gacek91 commented May 22, 2018

I tried doing that as well before, doesn't work because there's no such keyword argument:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-199-b92eb29f728c> in <module>()
      1 import pymatbridge as pymat
      2 ip = get_ipython()
----> 3 pymat.load_ipython_extension(ip, executable='/Applications/MATLAB_R2018a.app/bin/matlab')

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymatbridge/matlab_magic.py in load_ipython_extension(ip, **kwargs)
    208     global _loaded
    209     if not _loaded:
--> 210         ip.register_magics(MatlabMagics(ip, **kwargs))
    211         _loaded = True
    212 

TypeError: __init__() got an unexpected keyword argument 'executable'

@arokem
Copy link
Owner

arokem commented May 22, 2018

Oh - I think that's because it doesn't follow the same API.

https://github.com/arokem/python-matlab-bridge/blob/master/pymatbridge/matlab_magic.py#L53

Could you please try the following?

pymatbridge.load_ipython_extension(ip, matlab='/Applications/MATLAB_R2018a.app/bin/matlab')

@gacek91
Copy link
Author

gacek91 commented May 22, 2018

Damn, it works! Cheers!

@arokem
Copy link
Owner

arokem commented May 22, 2018 via email

mateusz-was added a commit to mateusz-was/python-matlab-bridge that referenced this issue Jul 31, 2018
Including README changes that are described in arokem#258.
This took me way to much time to find, so I hope this can get better exposure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants