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

ModuleNotFoundError: No module named 'exceptions' #247

Open
Kev1n3zz opened this issue Mar 9, 2022 · 5 comments
Open

ModuleNotFoundError: No module named 'exceptions' #247

Kev1n3zz opened this issue Mar 9, 2022 · 5 comments

Comments

@Kev1n3zz
Copy link

Kev1n3zz commented Mar 9, 2022

I download the code on my computer with python3.10.x.
After following the installation, there shows an error.

$ ./mwe.py rcc8
Traceback (most recent call last):
  File "C:\Users\zhangmanyu\Desktop\QSR推理\strands_qsr_lib\qsr_lib\scripts\mwe.py", line 10, in <module>
    from qsrlib.qsrlib import QSRlib, QSRlib_Request_Message
  File "c:\Users\zhangmanyu\Desktop\QSR推理\strands_qsr_lib\qsr_lib\src\qsrlib\qsrlib.py", line 8, in <module>
    from qsrlib_qsrs import *
  File "c:\Users\zhangmanyu\Desktop\QSR推理\strands_qsr_lib\qsr_lib\src\qsrlib_qsrs\__init__.py", line 9, in <module>
    from qsr_qtc_b_simplified import QSR_QTC_B_Simplified
  File "c:\Users\zhangmanyu\Desktop\QSR推理\strands_qsr_lib\qsr_lib\src\qsrlib_qsrs\qsr_qtc_b_simplified.py", line 3, in <module>
    from qsrlib_qsrs.qsr_qtc_simplified_abstractclass import QSR_QTC_Simplified_Abstractclass
  File "c:\Users\zhangmanyu\Desktop\QSR推理\strands_qsr_lib\qsr_lib\src\qsrlib_qsrs\qsr_qtc_simplified_abstractclass.py", line 6, in <module>
    from exceptions import Exception, AttributeError
ModuleNotFoundError: No module named 'exceptions'

I checked the file and the installation, it has't notes what the exceptions are.
And StackOverflow found no answer :)

How could i fix this problem?

@VVogelimkafig
Copy link

VVogelimkafig commented Mar 29, 2022

i have the same problem, i installed the python-docx but still have this error

@Geguze
Copy link

Geguze commented Apr 21, 2022

Having a similar issue but with a different module:

$ ./mwe.py rcc8                                                                                   
Traceback (most recent call last):
  File "/home/user/strands_qsr_lib/qsr_lib/scripts/./mwe.py", line 4, in <module>
    from qsrlib.qsrlib import QSRlib, QSRlib_Request_Message
  File "/home/user/strands_qsr_lib/qsr_lib/src/qsrlib/qsrlib.py", line 8, in <module>
    from qsrlib_qsrs import *
  File "/home/user/strands_qsr_lib/qsr_lib/src/qsrlib_qsrs/__init__.py", line 1, in <module>
    from qsr_rcc2 import QSR_RCC2
ModuleNotFoundError: No module named 'qsr_rcc2'

PYTHONPATH is correctly set. Any suggestion?

@Kev1n3zz
Copy link
Author

Kev1n3zz commented Apr 22, 2022 via email

@muelthom
Copy link

I'm currently running on Python 3.9.12 and faced the same issues mentioned above.

I am by no means a Python expert but with a few minor modifications I managed to make the MWE working. Here are the steps I made:

  1. In qsrlib_qsrs/__init__.py change the module import to relative paths:
    (e.g., change from qsr_rcc2 import QSR_RCC2 to from .qsr_rcc2 import QSR_RCC2)
  2. For the ModuleNotFoundError: No module named 'exceptions' error in qsrlib_qsrs/qsr_qtc_simplified_abstractclass.py simply remove the from exceptions import Exception, AttributeError import since it is not necessary in Python 3
  3. In the same file (see above) replace every xrange() call with range()
  4. In qsrlib_qsrs/qsr_arg_prob_relations_distance.py again change the module import to relative path:
    from .qsr_arg_relations_distance import QSR_Arg_Relations_Distance
  5. It seems that for the function _return_bounding_boxes_2d() in qsrlib_qsrs/qsr_monadic_abstractclass.py the return value which is a tuple must be explicitly made a tuple by just surrounding the return value:
    raise (data1.return_bounding_box_2d(), data2.return_bounding_box_2d())
  6. Lastly, to fix the error TypeError: 'dict_keys' object is not subscriptable which originates from make_world_qsr_trace() in qsrlib_qsrs/qsr_dyadic_abstractclass.py apply the following fix:
    qsrs_for = self._process_qsrs_for(list(world_state.objects.keys()), req_params["dynamic_args"])

Then the MWE can be executed successfully:

./mwe.py rcc8
['argd', 'argprobd', 'cardir', 'mos', 'mwe', 'qtcbcs', 'qtcbs', 'qtccs', 'ra', 'rcc2', 'rcc3', 'rcc4', 'rcc5', 'rcc8', 'tpcc']
rcc8 request was made at  2022-04-24 10:46:43.359738 and received at 2022-04-24 10:46:43.359747 and finished at 2022-04-24 10:46:43.359998
---
Response is:
0.0: o1,o2:{'rcc8': 'po'}; o1,o3:{'rcc8': 'po'}; o2,o1:{'rcc8': 'po'}; o2,o3:{'rcc8': 'po'}; o3,o1:{'rcc8': 'po'}; o3,o2:{'rcc8': 'po'}; 
1.0: o1,o2:{'rcc8': 'po'}; o1,o3:{'rcc8': 'po'}; o2,o1:{'rcc8': 'po'}; o2,o3:{'rcc8': 'po'}; o3,o1:{'rcc8': 'po'}; o3,o2:{'rcc8': 'po'}; 
2.0: o1,o2:{'rcc8': 'po'}; o1,o3:{'rcc8': 'po'}; o2,o1:{'rcc8': 'po'}; o2,o3:{'rcc8': 'po'}; o3,o1:{'rcc8': 'po'}; o3,o2:{'rcc8': 'po'};

Of course this rather is a "hacky" solution and for other calculi maybe additional fixes are necessary. The problem most likely stems from migrating from Python 2 to Python 3. Maybe the code just works fine with Python 2 but I can't confirm that since I've no ancient Python version installed :^)

@Kev1n3zz
Copy link
Author

Kev1n3zz commented Oct 11, 2022 via email

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

4 participants