17

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?

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
Asoul
  • 996
  • 1
  • 10
  • 22

2 Answers2

19

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

hspandher
  • 15,934
  • 2
  • 32
  • 45
6

You can also rename tasks.py to the name of your choice and can run it with '-c' option.

Suppose below is your simple py file named as 'invoke_testing.py'

from invoke import task

@task
def check_config_files(c):
    print("Hey I am Checking configurations")

You need to run through command line like this: for example to list down the availabe tasks

invoke -c invoke_testing --lists

which outputs:

Available tasks:
  check-config-files

p.s. '_' has been replace with '-' in the function name and if you need to run a specific task, it has be run with name as listed in the list.

invoke -c invoke_testing check-config-files

I got this reference from this source Python Invoke

Let me know if anyone gets more information around this.

vikrant rana
  • 4,509
  • 6
  • 32
  • 72