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

Initialization #2

Open
swiftvictor opened this issue Dec 11, 2018 · 4 comments
Open

Initialization #2

swiftvictor opened this issue Dec 11, 2018 · 4 comments

Comments

@swiftvictor
Copy link

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?

@azhe825
Copy link
Collaborator

azhe825 commented Dec 11, 2018

@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.

@FahmidMorshed
Copy link
Collaborator

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.

@yrahul3910
Copy link

yrahul3910 commented Sep 25, 2019

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

from util.mar import MAR

@azhe825
Copy link
Collaborator

azhe825 commented Sep 25, 2019

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.

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