1

In Pycharm CE I imported the project like this:

|- MyFramework
 |- __init__.py  
 |- AutomationFramework 
  |- __init__.py
  |- File_1.py 
  |- MainClass.py

and file_1 contends:

import AutomationFramework.MainClass as MainClass

def test_my_iot():
mc = MainClass.MainClass()

And it works when I double click in file1 and select "Run"

but using command lines is not working:

MyFramework $ python AutomationFramework/isolated_test_1.py 
Traceback (most recent call last):
File "AutomationFramework/isolated_test_1.py", line 3, in <module>
import AutomationFramework.MainClass as MainClass
ImportError: No module named AutomationFramework.MainClass  
MacPC:MyFramework $ 

I assume that I need to define the root of the project or something like that, but I really search around and I cannot found out what is wrong.

What PyCharm CE is working and with the terminal is not?

(edited to add the init.py that could have been the reason ).

MrAnderson
  • 11
  • 3

1 Answers1

0

It looks like you forgot __ init __.py files in MyFramework and AutomationFramework directories. Without that file python interpreter doesn't understand what is modules structure.

As I know PyCharm is very smart and try to build python path without __ init __.py. Interpreter is not so smart.

SkyFox
  • 1,805
  • 4
  • 22
  • 33
  • I check, I have __init__.py in both places. May not be pycharm is change some Pathlocations? if I remove "AutomationFramework" from everywhere it will work but I need this to integrate with other program. – MrAnderson May 24 '15 at 19:50
  • Can you share your sources with mw somewhere? I'm nothing to say more without it :( – SkyFox May 25 '15 at 06:40
  • yes, sure. https://github.com/brunofgs/MyFramework Here it's a sample. Thank you for your time. – MrAnderson May 25 '15 at 20:03