# Module Directory?

**URL:** https://discuss.tryton.org/t/module-directory/7532
**Category:** Developer
**Created:** [August 8, 2024, 1:58pm UTC](https://discuss.tryton.org/t/module-directory/7532 "2024-08-08T13:58:50Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 8, 2024, 1:58pm UTC](https://discuss.tryton.org/t/module-directory/7532/1 "2024-08-08T13:58:50Z")

</div>

So, I know how to make a module with cookiecutter, but how do i really install it? I mean should I make them in /home/pathos/path/d/lib/python3.12/site-packages/trytond/modules here? And then I run the admin-tryton stuff?

And theres another question. I have several modules I want to try that I don’t install with pip, how do I install it without having a conflict? Thank you so much.

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [August 8, 2024, 3:07pm UTC](https://discuss.tryton.org/t/module-directory/7532/2 "2024-08-08T15:07:47Z")

</div>

> [@mahija](#):
>
> So, I know how to make a module with cookiecutter, but how do i really install it?

Have a look at the [module tutorial](https://docs.tryton.org/latest/server/tutorial/module/setup.html).  
There most of your questions are answered.

> [@mahija](#):
>
> I mean should I make them in /home/pathos/path/d/lib/python3.12/site-packages/trytond/modules here?

Edit: Recommended installation method depends on what you are trying to do.  
While that can work, it is strongly discouraged.  
For testing and development you will find the following in the module tutorial:  
`python3 -m pip install --use-pep517 --editable opportunity`

> [@mahija](#):
>
> And then I run the admin-tryton stuff?

After you have installed/added a module you need to run:  
`trytond-admin -c trytond.conf -d databasename -m`.  
`-m` updates the module list.  
After adding or modifying it is necessary to restart the server so that the new code can be read, unless you are using `trytond --dev`.

> [@mahija](#):
>
> And theres another question. I have several modules I want to try that I don’t install with pip, how do I install it without having a conflict? Thank you so much.

Official tryton modules are designed to not conflict, but you do need to mind other module dependencies and external python dependencies.

---

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 9, 2024, 5:25am UTC](https://discuss.tryton.org/t/module-directory/7532/3 "2024-08-09T05:25:37Z")

</div>

Just to be sure, suppose I already make a whole module in trytond/modules, then in the folder i run` python3 -m pip install --use-pep517 --editable my_module_name`?

and another question can i modify official tryton modules?? and if i can edit my module/official module should i run this again` trytond-admin -c trytond.conf -d database name -m`? Thank you so much for answering. 😥😥😥😥😥😥

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [August 9, 2024, 8:47am UTC](https://discuss.tryton.org/t/module-directory/7532/4 "2024-08-09T08:47:53Z")

</div>

> [@mahija](#):
>
> Just to be sure, suppose I already make a whole module in trytond/modules, then in the folder i run` python3 -m pip install --use-pep517 --editable my_module_name`?

Either you install using the above command, or you put the directory containing the module in the trytond/modules directory, not both.

> [@mahija](#):
>
> and another question can i modify official tryton modules?? and if i can edit my module/official module should i run this again` trytond-admin -c trytond.conf -d database name -m`? Thank you so much for answering. 😥😥😥😥😥😥

I had the same idea when I started out using tryton.  
You CAN, but it will become a nightmare to maintain.  
Tryton modules are designed to be extended, so you can extend or override most aspects of a module without actually changing the original module. This is also covered in the module tutorial.

---

<div class="post-metadata">

### Author: ![htgoebel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/htgoebel/32/1256_2.png) [@htgoebel](https://discuss.tryton.org/u/htgoebel)
#### Post date: [August 14, 2024, 2:52pm UTC](https://discuss.tryton.org/t/module-directory/7532/5 "2024-08-14T14:52:18Z")

</div>

> [@mahija](#):
>
> I already make a whole module in trytond/modules

I _strongly_ suggest you to not do this. This is mixing installation and development. You will run into troubles more quickly than you think and you will end in a nightmare.

I suggest to:

- use a project directory per module
- install trytond in a virtual environment
- activate the virtual environment
- install your module in the virtual environment (using `pip` like @dotbit has shown)
- If your module depends on other custom modules, consider using a `requirements.txt` file to install these prior to installing your module
- For modifying official modules: Use an own custom module containing the modifications.

---

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 14, 2024, 5:29pm UTC](https://discuss.tryton.org/t/module-directory/7532/6 "2024-08-14T17:29:08Z")

</div>

Thank you.

I have made an env for this and i installed some official modules in that env. The modules are installed in myenv/lib/python/site-packages/trytond/modules/

In modules’ path there are gnuhealth modules and official modules. Since I want to develope my own modules should I make my custom module in that exact path? Or I could create another path for my custom modules?

---

<div class="post-metadata">

### Author: ![htgoebel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/htgoebel/32/1256_2.png) [@htgoebel](https://discuss.tryton.org/u/htgoebel)
#### Post date: [August 15, 2024, 9:27am UTC](https://discuss.tryton.org/t/module-directory/7532/7 "2024-08-15T09:27:26Z")

</div>

I suggest to use one separate path for every of your custom modules like this

```auto
.
├── my_module_1
│ ├── requirements.txt
│ ├── setup.py
│ ├── tryton.cfg
│ └── …
├── my_module_2
│ ├── requirements.txt
│ ├── setup.py
│ ├── tryton.cfg
│ └── …
└── _myvenv
    └── lib
        └── python
            └── site-packages
                └── trytond
                    └── modules/…

```

---

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 15, 2024, 1:36pm UTC](https://discuss.tryton.org/t/module-directory/7532/8 "2024-08-15T13:36:58Z")

</div>

> [@htgoebel](#):
>
> ```auto
> │ ├── setup.py
> │ ├── tryton.cfg
> │ └── …
> ├── my_module_2
> │ ├── requirements.txt
> │ ├── setup.py
> │ ├── tryton.cfg
> │ └── …
> └── _myvenv
> └── lib
> └── python
> └── site-packages
> └── trytond
> └── modules/…
> 
> ```

I get the gist of these, thank you. So i should run `python3 -m pip install --use-pep517 --editable my_module_name` with every name? I could not do this bundle?

P.S: I already did what you told: and after i run trytond-admin -c trytond.conf -d my\_database -m this errror shown: OSError: File not found : /home/username/.virtualenvs/folder\_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [August 16, 2024, 8:24am UTC](https://discuss.tryton.org/t/module-directory/7532/9 "2024-08-16T08:24:41Z")

</div>

> [@mahija](#):
>
> I get the gist of these, thank you. So i should run `python3 -m pip install --use-pep517 --editable my_module_name` with every name? I could not do this bundle?

Yes, every module needs to be installed.

> [@mahija](#):
>
> : /home/username/.virtualenvs/folder\_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg

What does `ls /home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg` result in?

BTW, your venv needs to be activated before you install your module, so that you are installing the module inside your venv.

---

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 16, 2024, 3:53pm UTC](https://discuss.tryton.org/t/module-directory/7532/10 "2024-08-16T15:53:23Z")

</div>

This: `ls /home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg`

Result in: `ls: cannot access '/home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg': No such file or directory`

But that was because absensi is a custom module, and why they would read a custom in `trytond/modules/`??

note: my venv is active

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [August 16, 2024, 4:13pm UTC](https://discuss.tryton.org/t/module-directory/7532/11 "2024-08-16T16:13:18Z")

</div>

Every module needs to have a tryton.cfg file. It does not matter if it is custom or official.

See [Anatomy of a module — Tryton server](https://docs.tryton.org/latest/server/tutorial/module/anatomy.html)

When trytond starts it reads all the installed modules, even not activated ones.  
If there is an error or something missing trytond will not start.

If you put `absensi` in your modules directory manually and you are not using it I recommend deleting it.

---

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 17, 2024, 2:29am UTC](https://discuss.tryton.org/t/module-directory/7532/12 "2024-08-17T02:29:00Z")

</div>

Of course I have trytond.cfg inside `absensi`. But somehow it could not read the trytond.cfg

because this path: `/home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg` is not the path of absensi modules.

This is my structure file, absensi is my module:

```auto
absentia/
┣ sao/
┣ absensi/
┃ ┣ data/
┃ ┣ locale/
┃ ┣ tests/
┃ ┣ doc/
┃ ┣ report/
┃ ┣ icons/
┃ ┣ security/
┃ ┣ wizard/
┃ ┣ view/
┃ ┣ exceptions.py
┃ ┣ core.py
┃ ┣ health_report.xml
┃ ┣ health.py
┃ ┣ tryton.cfg
┃ ┣ sequences.py
┃ ┣ MANIFEST.in
┃ ┣ setup.cfg
┃ ┣ setup.py
┃ ┣ abs_view.xml
┃ ┣ __init__.py
┃ ┣ COPYING
┃ ┣ PKG-INFO
┃ ┗ README.rst
┣ .reuse/
┃ ┗ dep5
┣ modules.rar
┣ version
┣ trytond.conf
┗ README.rst

```

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [August 17, 2024, 6:31am UTC](https://discuss.tryton.org/t/module-directory/7532/13 "2024-08-17T06:31:28Z")

</div>

It seems that I have confused you with the trytond/modules directory, and for that I apologize.  
There are multiple entry-points to a module depending on installation method, one of which is the module directory inside trytond directory.

> [@mahija](#):
>
> Of course I have trytond.cfg inside `absensi`

It should be tryton.cfg.

> [@mahija](#):
>
> because this path: `/home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg` is not the path of absensi modules.

Perhaps an old version of the module which is no longer there is registered in the database.  
Are you using an old database, or starting a new one?  
I would recommend checking that the module is installed using `pip list` and starting with a new database.

---

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 17, 2024, 7:16am UTC](https://discuss.tryton.org/t/module-directory/7532/14 "2024-08-17T07:16:33Z")

</div>

i mean tryton.cfg

> [@dotbit](#):
>
> It should be tryton.cfg.

> [@dotbit](#):
>
> I would recommend checking that the module is installed using `pip list` and starting with a new database.

it alrd installed in pip

> `(myenv) tst@DESKTOP-QK8AUMD:~/mydir$ pip list Package Version Editable project location --------------- ----------- ----------------------------------- Genshi 0.7.9 **hrms_absensi 6.0.0 /home/tst/mydir/absensi** lxml 5.3.0 passlib 1.7.4 pip 24.1.2 polib 1.2.0 psycopg2 2.9.9 python-dateutil 2.9.0.post0 python-magic 0.4.27 python-sql 1.5.1 relatorio 0.10.2 setuptools 71.0.4 six 1.16.0 trytond 6.0.0 Werkzeug 1.0.1 wheel 0.43.0 wrapt 1.16.0`

I try to run `trytond-admin -c configuration -d databasename --all` after installing with `$ python3 -m pip install --use-pep517 --editable absensi` it keep showing error like this:

```auto
(myvenv) tst@DESKTOP-QK8AUMD:~/mydir$ trytond-admin -c configuration -d database name
Traceback (most recent call last):                                                                                                                                        
File "/home/tst/.virtualenvs/virtualname/bin/trytond-admin", line 23, in <module>                                                                                    
admin.run(options)                                                                                                                                                    
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/admin.py", line 53, in run                                                             
pool.init(update=options.update, lang=list(lang),                                                                                                                     
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-packages/trytond/pool.py", 
line 152, in init                                                            
self.start()                                                                                                                                                          
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-packages/trytond/pool.py", 
line 105, in start                                                           
register_classes()                                                                                                                                                    
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/modules/ __init__.py", line 338, in register_classes                                    
for node in create_graph(get_module_list()):                                                                                                                          
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/modules/ __init__.py", line 147, in create_graph                                        
info = get_module_info(module)                                                                                                                                        
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/modules/ __init__.py", line 85, in get_module_info                                      
with tools.file_open(os.path.join(name, 'tryton.cfg')) as fp:                                                                                                         
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/tools/misc.py", line 78, in file_open                                                  

raise IOError('File not found : %s ' % name)                                                                                                                       
OSError: File not found : /home/tst/.virtualenvs/virtualname/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg

```

---

<div class="post-metadata">

### Author: ![htgoebel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/htgoebel/32/1256_2.png) [@htgoebel](https://discuss.tryton.org/u/htgoebel)
#### Post date: [August 17, 2024, 8:39am UTC](https://discuss.tryton.org/t/module-directory/7532/15 "2024-08-17T08:39:56Z")

</div>

> [@mahija](#):
>
> P.S: I already did what you told: and after i run trytond-admin -c trytond.conf -d my\_database -m this errror shown: OSError: File not found : /home/username/.virtualenvs/folder\_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg

This error message is often misleading. This often means that your module fails to import (due to an error in your module). Just add a `raise` in front of [line 77 in trytond/tools/misc.py](https://foss.heptapod.net/tryton/tryton/-/blob/branch/7.0/trytond/trytond/tools/misc.py?ref_type=heads#L77). nly use this in your development environment!

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [August 17, 2024, 8:59am UTC](https://discuss.tryton.org/t/module-directory/7532/16 "2024-08-17T08:59:36Z")

</div>

Thank you @htgoebel, I will keep that in mind. That was beyond my knowledge.  
@mahija The technique I use to avoid such errors is to make really small steps, then test and when you get an error you know which step produced the error.

---

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 17, 2024, 12:10pm UTC](https://discuss.tryton.org/t/module-directory/7532/17 "2024-08-17T12:10:04Z")

</div>

I assume the link you gave me was trytond 7.2. I forgot to mention it was trytond 6.0 and the line in misc.py is a bit differen(that already bin raised)t:

> ```
> if subdir:
> if (subdir == 'modules'
> and (name.startswith('ir' + os.sep)
> or name.startswith('res' + os.sep)
> or name.startswith('tests' + os.sep))):
> name = secure_join(root_path, name)
> else:
> name = secure_join(root_path, subdir, name)
> else:
> name = secure_join(root_path, name)
> 
> for i in (name, egg_name):
> if i and os.path.isfile(i):
> return io.open(i, mode, encoding=encoding)
>         
> raise IOError('File not found : %s ' % name)
> 
> ```

---

<div class="post-metadata">

### Author: ![htgoebel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/htgoebel/32/1256_2.png) [@htgoebel](https://discuss.tryton.org/u/htgoebel)
#### Post date: [August 25, 2024, 11:44am UTC](https://discuss.tryton.org/t/module-directory/7532/18 "2024-08-25T11:44:30Z")

</div>

Oh, you are still on 6.0. AFAIU you are using GnuHealth and assume GnuHealth is still on 6.0. Otherwise I’s strongly suggest to start new projects with the current TLS version.

In 6.0 the behavior was quite different and even worse. Since there are many possibilities why this can fail, I suggest to add this before line 42 and step through the code.

```auto
    if module_name == 'absensi': breakpoint()

```
