See if it works like this:
1) Create the initial structure (Abaixos commands are for linux)
$ mkdir -p gestao/aplicacao/autorizacoes
2) Create the files __init__.py
$ touch gestao/__init__.py
$ touch gestao/autorizacoes/__init__.py
3) In the authorizations folder create and edit a file with the name hello.py
and add the following content:
def hellow():
return 'Hello World!'
4) In the root folder (gestao), create the file sayhello.py
with the following content:
from aplicacao.autorizacoes.hello import hellow
With the command tree
you can see the estrtura:
$ tree
.
├── aplicacao
│ ├── autorizacoes
│ │ ├── hello.py
│ │ └── __init__.py
│ └── __init__.py
└── sayhello.py
5) Execute sayhello.py
at the command line:
$ python sayhello.py
The output should be:
Hello World!
Edited
Reviewing the code in your question, it is unclear whether Authorizations is a package or a module, whether you have doubts as to whether it is a package and/or a module, see this answer here in Stopt. In the example code of your question, you ask: import autorizacoes
, but if authorizations are a package (a package can be summarized as a directory containing modules), you should do: import autorizacoes.nome_do_modulo
In python, for a directory to be a module you need to add a file as the name
__init__.py
.– Sidon
Yes, inside the "authorizations" folder I already have a file called "init.py"
– Brenda Xavier
But it’s not enough to be
init.py
has to be__init__.py
, that is to start and end with 2 "underlines".– Sidon
Also, the python is case-sensitive, or be you have to use the
A
uppercase as you put it in the folder name– nosklo
I did that too and you keep making the same mistake
– Brenda Xavier
You tried my answer?
– Sidon