victorlei / smop

Small Matlab to Python compiler
MIT License
1.08k stars 409 forks source link

Doesn't work: python main.py fastsolver.m AND smop fastsolver.m #188

Closed p-mackay closed 1 year ago

p-mackay commented 1 year ago

(1) paul@jaro smop/smop$ python main.py solver.m Traceback (most recent call last): File "/home/paul/smop/smop/main.py", line 15, in from . import options ImportError: attempted relative import with no known parent package

(2) paul@jaro smop/smop$ smop solver.m Traceback (most recent call last): File "/home/paul/.local/bin/smop", line 33, in sys.exit(load_entry_point('smop', 'console_scripts', 'smop')()) File "/home/paul/.local/bin/smop", line 25, in importlib_load_entry_point return next(matches).load() File "/usr/lib/python3.10/importlib/metadata/init.py", line 171, in load module = import_module(match.group('module')) File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/home/paul/smop/smop/main.py", line 17, in from . import resolve File "/home/paul/smop/smop/resolve.py", line 22, in import networkx as nx File "/home/paul/.local/lib/python3.10/site-packages/networkx/init.py", line 84, in import networkx.generators File "/home/paul/.local/lib/python3.10/site-packages/networkx/generators/init.py", line 5, in from networkx.generators.classic import File "/home/paul/.local/lib/python3.10/site-packages/networkx/generators/classic.py", line 21, in from networkx.algorithms.bipartite.generators import complete_bipartite_graph File "/home/paul/.local/lib/python3.10/site-packages/networkx/algorithms/init.py", line 12, in from networkx.algorithms.dag import File "/home/paul/.local/lib/python3.10/site-packages/networkx/algorithms/dag.py", line 2, in from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py)

Any idea's what went wrong?

RobBW commented 1 year ago

Have you read back over the previously reported issues?Based on a quick look at your traceback the answers can be found there.RegardsRob WilkinsonOn 12/02/2023, at 16:04, Paul MacKay @.> wrote: (1) @. smop/smop$ python main.py solver.m Traceback (most recent call last): File "/home/paul/smop/smop/main.py", line 15, in from . import options ImportError: attempted relative import with no known parent package (2) @.** smop/smop$ smop solver.m Traceback (most recent call last): File "/home/paul/.local/bin/smop", line 33, in sys.exit(load_entry_point('smop', 'console_scripts', 'smop')()) File "/home/paul/.local/bin/smop", line 25, in importlib_load_entry_point return next(matches).load() File "/usr/lib/python3.10/importlib/metadata/init.py", line 171, in load module = import_module(match.group('module')) File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/home/paul/smop/smop/main.py", line 17, in from . import resolve File "/home/paul/smop/smop/resolve.py", line 22, in import networkx as nx File "/home/paul/.local/lib/python3.10/site-packages/networkx/init.py", line 84, in import networkx.generators File "/home/paul/.local/lib/python3.10/site-packages/networkx/generators/init.py", line 5, in from networkx.generators.classic import File "/home/paul/.local/lib/python3.10/site-packages/networkx/generators/classic.py", line 21, in from networkx.algorithms.bipartite.generators import complete_bipartite_graph File "/home/paul/.local/lib/python3.10/site-packages/networkx/algorithms/init.py", line 12, in from networkx.algorithms.dag import * File "/home/paul/.local/lib/python3.10/site-packages/networkx/algorithms/dag.py", line 2, in from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py) Any idea's what went wrong?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

p-mackay commented 1 year ago

I got it working. Thank you for your comment. I went over the other issues opened. Here's what I did: Make sure you read the INSTALL file in smop/ (1) all in the same directory virtualenv smop source bin/activate pip install --upgrade pip pip install -e .

(2) in smop/smop/resolve.py you have to change "node" to "nodes" in the following lines: 54 and 66 u = G.nodes[n]["ident"] G.nodes[n]["label"] = "%s\n%s" % (n, u.props)

(3) in smop/smop/main.py instead of: from . import package should be: from smop import package

Hopefully this works for you as it worked for me! :)

RobBW commented 1 year ago

Great! Here are some notes I made about a year ago which may be of interest for you.

***Pythonic smop: https://github.com/PatrickFURI/smop +24 ahead

Makes some worthwhile improvements

*****2022 Note:* This has already been done at: https://github.com/smop3/smop

Smop3 is the community maintained version of https://github.com/victorlei/smop/ abandoned somewhere around 2018.

SMOP is looking for maintainers and people with knowledge on lexers and parsers to help clean up the project! Dec 2021

Redeveloping SMOP

The lexer and Parser in smop could now be replaced by Miss_Hit.https:// misshit.org

https://github.com/florianschanda/miss_hit

There have been other attempts at this, but MISS_HIT tries to do things differently (and I hope better). Specifically:

On Mon, Feb 13, 2023 at 8:09 PM Paul MacKay @.***> wrote:

I got it working. Thank you for your comment. I went over the other issues opened. Here's what I did: Make sure you read the INSTALL file in smop/ (1) all in the same directory virtualenv smop source bin/activate pip install --upgrade pip pip install -e .

(2) in resolve.py you have to change "node" to "nodes" in the following lines: 54 and 66 u = G.nodes[n]["ident"] G.nodes[n]["label"] = "%s\n%s" % (n, u.props)

(3) in main.py instead of: from . import package should be: from smop import package

Hopefully this works for you as it worked for me! :)

— Reply to this email directly, view it on GitHub https://github.com/victorlei/smop/issues/188#issuecomment-1427451916, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRNQJSOQDGVYUNGNEVOYFTWXHM2XANCNFSM6AAAAAAUZC7AVU . You are receiving this because you commented.Message ID: @.***>