seomoz / shovel

Rake, for Python
MIT License
660 stars 49 forks source link

ModuleNotFoundError. Shovel can't find relative modules #39

Open ferrerluis opened 6 years ago

ferrerluis commented 6 years ago

My directory structure looks like this:

# some_class.py

class SomeClass:
    def execute(self):
        print("Test")

My shovel.py looks like this:

from shovel import task
from helpers.some_class import SomeClass

@task
def use_class():
    some_class = SomeClass()
    some_class.execute()

Then within the directory project I run shovel use_class. The error I get is ModuleNotFoundError: No module named 'helpers'

However, if I drop shovel and simply run python shovel.py, it works just fine. e.g.

from helpers.some_class import SomeClass

def use_class():
    some_class = SomeClass()
    some_class.execute()

use_class()
moribellamy commented 6 years ago

i'm also having library loading issues. interpreting my file (which has @tasks inside) works fine, but shovel wont load my relative import. in my case its in the same directory, not under a "helpers".

[0] 05:04:07 {master} ~/.shovel$ shovel test.coverage
Traceback (most recent call last):
  File "/Users/moribellamy/venv/shovel/bin/shovel", line 11, in <module>
    sys.exit(run())
  File "/Users/moribellamy/venv/shovel/lib/python2.7/site-packages/shovel/runner.py", line 70, in run
    shovel.read(path, os.path.expanduser('~/'))
  File "/Users/moribellamy/venv/shovel/lib/python2.7/site-packages/shovel/tasks.py", line 98, in read
    tasks.extend(Task.load(absolute, base))
  File "/Users/moribellamy/venv/shovel/lib/python2.7/site-packages/shovel/tasks.py", line 181, in load
    imp.load_module(name, fobj, path, description)
  File "/Users/moribellamy/.shovel/db.py", line 7, in <module>
    from lib import nonce
ImportError: No module named lib
[1] 05:04:19 {master} ~/.shovel$ python test.py
[0] 05:04:26 {master} ~/.shovel$
moribellamy commented 6 years ago

if i rename "db.py" in my example above to "z.py" it works

nelsonmestevao commented 4 years ago

Any ideia how to fix this?