normyx / MMM-Facial-Recognition-OCV3

MIT License
51 stars 18 forks source link

No module named 'config' #3

Open SofiaGR opened 6 years ago

SofiaGR commented 6 years ago

Hello @normyx ,

I recently found this module and installed all the requirements successfully. However, when I run the command

python tools.capture.py

I always run into the error

Traceback (most recent call last):
    File "tools.capture.py", line 9, in <module>
       from lib.tools.capture import ToolsCapture
    File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/lib/tools/capture.py", line 20 in <module>
       from config import ToolsConfig
ImportError: No module named 'config'

Do you have any clues what I might be missing?

Thanks!

normyx commented 6 years ago

Hi @SofiaGR

What is your python version. I made the tests with version 2.7 as far as I remember. But it is very strange ... can you check if you have the file /lib/common/config.py ?

KR

SofiaGR commented 6 years ago

Hello @normyx

I'm using python 3.5.3 with opencv 3.3.1.

And I don't have a config.py file in the common folder, besides commonconfig.py. The config file it can't locate is in the /lib/tools. Should it be in lib/common/?

normyx commented 6 years ago

Hi Sorry, I had a wrong analyze. Could you please make a test with python 2.7 ? Do you have the file config.py in lib/tools/ ?

SofiaGR commented 6 years ago

Hello @normyx

At the moment, I only have Opencv built for python 3.5.3. I can compile it for python 2.7 and see how it goes.

The file config.py is in that folder however, but it can't seem to find it. :/

normyx commented 6 years ago

Can you try to put up the import line from config import ToolsConfig just before theimport cv2?

SofiaGR commented 6 years ago

Still the same error when I import cv2 after the config import.

normyx commented 6 years ago

Hi

Sorry, I do not see any more clue, and unfortunately I am not a python expert 🤔

Le 23 févr. 2018 19:00, "Sofia" notifications@github.com a écrit :

Still the same error when I import cv2 after the config import.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/normyx/MMM-Facial-Recognition-OCV3/issues/3#issuecomment-368089259, or mute the thread https://github.com/notifications/unsubscribe-auth/AhrZlXuLaKb4tCEeS2tRqa3siiYIRukuks5tXvyxgaJpZM4SN3Gg .

inderpartap commented 6 years ago

@SofiaGR, download this repository once again. Make sure you have a config.py file in the lib/tools folder

normyx commented 6 years ago

Hi @SofiaGR , did you solve your issue (to clore that thread)?

SofiaGR commented 6 years ago

Going to try downloading this repository again. Couldn't do anything during the weekend since the raspberry was at work.

SofiaGR commented 6 years ago

I downloaded the repository again and verified I do have the config.py file in the lib/tools folder. The error remains the same. You worked on this using python 2.7 and Opencv 3+ right? So I can only assume the issue derives from me using python 3.5.3.

inderpartap commented 6 years ago

Importing a file in Python3 is different. In Python 3 all imports are absolute unless a relative path is given to perform the import from. You will either need to use an absolute or relative import. In line 19of capture.py (lib/tools/capture.py), change it to from .config import ToolsConfig

SofiaGR commented 6 years ago

Annnd just like that it's fixed ^^; I knew it was something related to python 3

Thank you @inderpartap for your help!

And of course thanks as well @normyx :) It appears to be working now o/

Feel free to close this :D

normyx commented 6 years ago

Hi all,

thank you very much. @inderpartap : Do you know how to import in a way to be compatible for python 2.7 and 3.0 ?

Regards

inderpartap commented 6 years ago

Hey @normyx. Giving a relative path for the file is compatible with both Python 2.x and 3.x. You can change line 19 in capture.py permanently to - from .config import ToolsConfig. It should work on both the versions without any errors.

normyx commented 6 years ago

Thx, I will try before closing the issue.

E3V3A commented 6 years ago

@normyx Any updates?

normyx commented 6 years ago

Not yet, no time for this right now ;o)

MuhammadJamee commented 6 years ago

install Python 2.7 and everything will work fine, python3 pop up errors for me on Pi3, but same code run smooth on 2.7, just follow the instruction as given

normyx commented 6 years ago

No update. No time to update and check with Python 3.X ... sorry !