src icon indicating copy to clipboard operation
src copied to clipboard

Initialization

Open swiftvictor opened this issue 7 years ago • 4 comments

Python does not recognize this code: from mar import MAR

"ModuleNotFoundError: No module named 'mar'"

The following does not return any relevant packages: conda install -y mar

I am running the code on a MacOS with Python 3.6.5 and conda 4.5.11. Could this be a version issue?

swiftvictor avatar Dec 11 '18 14:12 swiftvictor

@swiftvictor you are right. It only works with Python 2.7 right now.

We are trying to make it compatible with Python 3 but if you want to use it now, please use Python 2.

P.S. Feel free to submit a pull request if you are able to make it compatible with Python 3.

azhe825 avatar Dec 11 '18 23:12 azhe825

Hi @swiftvictor,

I pulled the repo and run on my local. I have python 3.7. It works fine. I do not think it has anything to do with version issue. Rather, the IDE needs to understand the "source root" to find the relevant class (mar.py). If you are using PyCharm, in the Project Explorer, right click on the inner src folder (src/src) and there should be an option called "Mark Directory as -> source". This should resolve the directory. If you are using any other IDE, try finding the same option.

Also, if you want to change the version of the python file, try this https://docs.python.org/2/library/2to3.html This will automatically convert the python 2 codes into a python 3 code. But, as I have said earlier, I am running python3.7 and it is working for me without any issue.

FahmidMorshed avatar Dec 12 '18 02:12 FahmidMorshed

I had the same issue with Python 2.7 as well as Python 3. I believe it should be

from util.mar import MAR

yrahul3910 avatar Sep 25 '19 18:09 yrahul3910

import os
import sys

root = os.getcwd().split("src")[0] + "src/src/util"
sys.path.append(root)

The above code should add util to the source root so that

from mar import MAR

should be correct. Not sure why sometimes it does not work.

azhe825 avatar Sep 25 '19 18:09 azhe825