# nameko services in multiple files

**URL:** <https://discourse.nameko.io/t/nameko-services-in-multiple-files/686>\
**Category:** Uncategorized\
**Created:** [April 7, 2021, 1:17pm UTC](https://discourse.nameko.io/t/nameko-services-in-multiple-files/686 "2021-04-07T13:17:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sugizo](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/sugizo/32/136_2.png) [@sugizo](https://discourse.nameko.io/u/sugizo)\
**Post date:** [April 7, 2021, 1:17pm UTC](https://discourse.nameko.io/t/nameko-services-in-multiple-files/686/1 "2021-04-07T13:17:54Z")

</div>

**test.py**

```auto
from .test0 import *
from .test1 import *

```

**test0.py**

```auto
import json
from nameko.web.handlers import http
class InstallService:
    name = "install_service"
    @http('GET', '/get0/<int:value>')
    def get0(self, request, value):
        return json.dumps({'value': value})
    @http('POST', '/post0')
    def post0(self, request):
        return u"received: {}".format(request.get_data(as_text=True))

```

**test1.py**

```auto
import json
from nameko.web.handlers import http
class ApiService:
    name = "api_service"
    @http('GET', '/get1/<int:value>')
    def get1(self, request, value):
        return json.dumps({'value': value})
    @http('POST', '/post1')
    def post1(self, request):
        return u"received: {}".format(request.get_data(as_text=True))

```

```auto
$ nameko run test
Traceback (most recent call last):
  File "/Users/MacBookPro/miniconda3/envs/python3_test/bin/nameko", line 8, in <module>
    sys.exit(main())
  File "/Users/MacBookPro/miniconda3/envs/python3_test/lib/python3.8/site-packages/nameko/cli/main.py", line 119, in main
    args.main(args)
  File "/Users/MacBookPro/miniconda3/envs/python3_test/lib/python3.8/site-packages/nameko/cli/commands.py", line 110, in main
    main(args)
  File "/Users/MacBookPro/miniconda3/envs/python3_test/lib/python3.8/site-packages/nameko/cli/run.py", line 181, in main
    import_service(path)
  File "/Users/MacBookPro/miniconda3/envs/python3_test/lib/python3.8/site-packages/nameko/cli/run.py", line 46, in import_service
    __import__ (module_name)
  File "./test.py", line 1, in <module>
    from .test0 import *
ImportError: attempted relative import with no known parent package

```

```auto
nameko==2.13.0
python 3.8

```

**question**  
how to use nameko services in multiple files ?

thanks

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [April 7, 2021, 1:21pm UTC](https://discourse.nameko.io/t/nameko-services-in-multiple-files/686/2 "2021-04-07T13:21:21Z")

</div>

This got caught in the spam filter. You typed it suspiciously fast, apparently 😉

This usage is correct. The only problem is that you’ve not got packaged the modules, so the relative import doesn’t work. Try this:

```auto
# test.py
from test0 import *
from test1 import *

```

In production I would recommend running a single service per process though.
