ValueError: Attempted relative import in non-package
Closed this issue · 0 comments
oshihirii commented
The following seemed to resolve an error I was getting when running the following in OpenShift:
python mongodb_backend.py
Background
Installed custom library from GitHub:
source ~/python/virtenv/bin/activate
pip install --log $OPENSHIFT_DATA_DIR/inst.log https://github.com/FedericoCeratto/bottle-cork/archive/master.zip
Running:
[<app>-<namespace>.rhcloud.com cork]\> python mongodb_backend.py
Traceback (most recent call last):
File "mongodb_backend.py", line 11, in <module>
from .base_backend import Backend, Table
ValueError: Attempted relative import in non-package
This blog post I think outlines a similar problem and solution well:
http://melitamihaljevic.blogspot.com.au/2013/04/python-relative-imports-hard-way.html
So in mongodb_backend.py
I changed:
from .base_backend import Backend, Table
to:
from base_backend import Backend, Table
and now I can run:
python mongodb_backend.py
I don't know if that has any other implications though.