Python Microservices with Nameko

546 Views Asked by At

I'm trying to follow the simple Python Microservices with Nameko example.

I have both rabbitmq and rabbitmq management running in dockers:

docker run -d --hostname my-rabbit --name some-rabbit rabbitmq:3

docker run -d --hostname my-rabbit --name mgmt-rabbit -p 15672:15672 rabbitmq:3-management

I can browse to http://localhost:15672 and it's running.

I have installed nameko by using:

pip install nameko

Created my virtualenv and created helloworld.py:

# helloworld.py

from nameko.rpc import rpc

class GreetingService:
    name = "greeting_service"

    @rpc
    def hello(self, name):
        return "Hello, {}!".format(name)

If I run any of these commands:

nameko run helloworld

nameko run helloworld:GreetingService

nameko run helloworld --broker amqp://guest:guest@localhost

I get this error:

Error: No module named 'helloworld'

What am I doing wrong?

1

There are 1 best solutions below

0
mNajarzadeh On

When python looks for a module , it will look at __init__.py in your directory , you must check you have __init__.py file in your helloworld.py directory .