pythonpython-3.xpython-2.7invokepyinvoke

Python Invoke - Can't find any collection named 'tasks'!


I did the getting started on Python Invoke

from invoke import task

@task
def build():
    print("Building!")

The expected output is

$ invoke build
Building!

However, my output is

$ invoke build
Can't find any collection named 'tasks'!

I have no idea why.

Something amazing is, once I invoke in the virtualenv, then I can build without virtualenv.

> mkvirtualenv myenv
> invoke build
Building!
> deactivate myenv
> invoke build
Building!

Did I miss something?


Solution

  • According to documentation your file containing task should be named tasks.py. Make sure you are running build from the same directory as tasks.py, too