Skip to content

Issues with imports when trying to run run-tests.py #17

Open

Description

@waynee95

Running python3.11 run-tests.py leads to the following error:

Traceback (most recent call last):
  File "/home/waynee95/Documents/python-student-support-code/run-tests.py", line 6, in <module>
    from interp_x86.eval_x86 import interp_x86
  File "/home/waynee95/Documents/python-student-support-code/interp_x86/eval_x86.py", line 9, in <module>
    from convert_x86 import convert_program
ModuleNotFoundError: No module named 'convert_x86'

I am not too familiar with the module system of python but I tried to add a dot in the import, i.e. from .convert_x86 import convert_program, but this will then lead to another error:

Traceback (most recent call last):
  File "/home/waynee95/Documents/python-student-support-code/run-tests.py", line 6, in <module>
    from interp_x86.eval_x86 import interp_x86
  File "/home/waynee95/Documents/python-student-support-code/interp_x86/eval_x86.py", line 10, in <module>
    from parser_x86 import x86_parser, x86_parser_instrs
ModuleNotFoundError: No module named 'parser_x86'

This will continue.

Activity

  1. Ray-Eldath commented on Mar 24, 2023

    @Ray-Eldath

    Same on my machine. The following patch should fix this:

    diff --git a/interp_x86/eval_x86.py b/interp_x86/eval_x86.py
    index d9e0146..a1a9b6a 100644
    --- a/interp_x86/eval_x86.py
    +++ b/interp_x86/eval_x86.py
    @@ -6,8 +6,8 @@ from dataclasses import dataclass
     
     from utils import *
     
    -from interp_x86.convert_x86 import convert_program
    -from interp_x86.parser_x86 import x86_parser, x86_parser_instrs
    +from convert_x86 import convert_program
    +from parser_x86 import x86_parser, x86_parser_instrs
     
     
     def interp_x86(program):
    diff --git a/utils.py b/utils.py
    index 7a7557b..8185cc5 100644
    --- a/utils.py
    +++ b/utils.py
    @@ -1182,7 +1182,7 @@ def compile_and_test(compiler, compiler_name,
                          program_filename):
         total_passes = 0
         successful_passes = 0
    -    from interp_x86.eval_x86 import interp_x86
    +    from eval_x86 import interp_x86
     
         program_root = os.path.splitext(program_filename)[0]
         with open(program_filename) as source:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions