Unresolved reference python and project structure

I created a project. Project name is awesomeapplication. My packages are api, application. Then there is tmp package as well where I have the file.

├── awesomeapplication
│   ├── api
│   │   ├──
│   │   └──
│   ├──
│   ├── application
│   │   ├──
│   │   └──
│   ├── requirements.txt
│   ├── tmp
│   │   ├──
│   │   └──
│   └──

Now, in file when I call,

from api import awesomeappapi, it should work. As ‘api’ is a package (with ).

But there is a unresolved reference error. And I was scratching my head for sometimes. Then, I checked

In File->Settings->project structure. And saw that my project root “awesomeapplication” was not included in source, rather the parent directory was.

Screenshot from 2017-05-07 12:24:17

So, myproject->awesomeapplication was folder structure and myproject was in sources, but not awesomeapplication.

So, I added awesomeapplication in sources. And problem was solved.

I learned that, when there are packages in a project, they will be discoverable in other packages only when the project root are added in ‘Sources’.

Very important to learn this basic thing right?

Thanks and Greetings.


One thought on “Unresolved reference python and project structure

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s