Forum Archive

Attempted relative import in non-package

Webmaster4o

I get this error when I call import gittle (after installing both gittle and dulwich), which, from what I understand, should only exist if running the script directly, not if I call import. What's up win this? Does pythonista not change __name__, or am I confused? How can I fix this?

dgelessus

Are you running this in the interactive interpreter, or is there other code that runs before the import? Also where did you install gittle, and does it have a __init__.py file in the package folder?

Webmaster4o

I installed it from GitHub, just running the import statement. I fixed the problem by renaming some files and removing some relative imports.