bastibe / transplant

Transplant is an easy way of calling Matlab from Python
https://transplant.readthedocs.io
Other
110 stars 26 forks source link

Using transplant with Python 2.7 #35

Closed alexjwilliams closed 7 years ago

alexjwilliams commented 7 years ago

I tried importing transplant in Python 2.7, but got the following error:

Traceback (most recent call last): File "Experiment.py", line 19, in import transplant File "/usr/local/lib/python2.7/dist-packages/transplant/init.py", line 1, in from .transplant_master import Matlab, TransplantError, MatlabStruct File "/usr/local/lib/python2.7/dist-packages/transplant/transplant_master.py", line 123 print(line.decode(), end='')

I believe this occurs because you are using the print statement from Python 3.

@bastibe , how hard do you believe it would be to make transplant usable in Python 2.7? I can definitely attempt to do this on my own, but I would like some background info to guide me.

Thanks, Alex Williams

bastibe commented 7 years ago

It shouldn't be very hard. The error you are seeing is easily fixed with from __future__ import print_function. Then, there are a few instances of keyword-only arguments and some tuple unpacking. The bytes/str-divide might also be an issue.

Be warned however, that I am not willing to sacrifice readability or functionality for the sake of Python 2, and I do not have the time to maintain separate Python 2 code paths. If at all possible, I would strongly suggest you use Python 3.

alexjwilliams commented 7 years ago

I have decided to just try using python 3. I ran into some other issues in addition to the ones you pointed out when I was working on converting the code.