Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError. Shovel can't find relative modules #39

Open
ferrerluis opened this issue Feb 6, 2018 · 3 comments
Open

ModuleNotFoundError. Shovel can't find relative modules #39

ferrerluis opened this issue Feb 6, 2018 · 3 comments

Comments

@ferrerluis
Copy link

My directory structure looks like this:

  • project
    • helpers
      • some_class.py
    • shovel.py
# 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
Copy link

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
Copy link

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

@nelsonmestevao
Copy link

Any ideia how to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants