I don’t know if this is connected with the writing, or if it’s me noob.
Here is a screenshot of my folder layout and three code files:
I use Pycharm for windows, and "my_working_directory" is my working directory. You can see in the screenshot that in mod1.py “from package2.mod2” underscores “unresolved link”.
When I try to run mod1.py, I get:
C:\Python27\python.exe C:/Users/Robert/PycharmProjects/play/my_working_directory/package1/mod1.py Traceback (most recent call last): File "C:/Users/Robert/PycharmProjects/play/my_working_directory/package1/mod1.py", line 1, in <module> from package2.mod2 import SomeClass ImportError: No module named package2.mod2
When I run main.py, I get:
C:\Python27\python.exe C:/Users/Robert/PycharmProjects/play/my_working_directory/main.py hi
I do not understand why one works and not the other.
The main problem is that pycharm does not give me autocompletion, and from mod1 it cannot detect package2. This is a huge problem because package1 is my view package, package2 is my models or utils or lib package (in a large model view controller). (example https://github.com/coto/gae-boilerplate/blob/master/web/handlers.py pycharm does not detect any of the lib.? import? statements (giving an unresolved link).
Does anyone know what is going on? Is this the best way to import packages? Should I expect you to have autocomplete?
Should "my_working_directory" turn into a package by creating another init .py file?
source share