-1

I am trying to convert Matlab file to Python so i found a library called smop. whenever i run a code that imports smop library, i get an error. Here is how I am importing smop

from smop.libsmop import *

this is the error message I am getting

python3.8/site-packages/smop-0.41b0-py3.8.egg/smop/libsmop.py", line 6, in ModuleNotFoundError: No module named 'builtin'

how can I fix this error?

e.iluf
  • 1,389
  • 5
  • 27
  • 69

2 Answers2

0

This question was asked earlier in the week. You need check with the authors of the package and perhaps file a bug report. It claims to be for Python 3, but it's using a Python2 construct. You can work around this by changing __builtin__ to builtins in that file, libsmop.py.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
0

Just use an updated fork of SMOP and after doing a: python setup.py install, you have to go to the directory your site-packages are in and unzip the .egg file. The project isn't maintained anymore. Anyhow, I forked it (from another Python 3 fork) and fixed a few more bugs here:

https://github.com/mattslezak-shell/smop/

Really I'd say it's for prototyping code from MATLAB. It has some interesting MATLAB compatibility layers implemented, and some of the things don't appear to do anything at all (like vargin/nargin), other than preserve the MATLAB-like structure.

Still even with it's strange format, I don't know of anything else that will auto convert most things over for you. You may need to add some import statements and refactor the code a bit, depending on the complexity of the .m file(s) you convert over. I suppose it beats manual conversion, but it still isn't a true "converter," more like a partial MATLAB wrapper. Some code just works, but many files need some imports added or other refactoring to get the desired result.

Nonetheless, it's good for testing out MATLAB code from Python at least...

Matt
  • 2,602
  • 13
  • 36