私はパッケージを持っていますcclogger
。このディレクトリには__init__.py
、構成をロードするためのコードを含むファイルがあります。api_main.py
次のコマンドを使用してそのディレクトリ内のファイルを実行しようとすると...
python -m cclogger.api_main
次のエラーが表示されます:-
config loaded
Instantiating DB with: cclogger/test123@localhost:x
Instantiated ParseCentral
Register parser called by : CitiIndia
Registered parser for email: CitiAlert.India@citicorp.com
Instantiated SmsParseCentral
Register parser called by : Citi Bank
Registered sms parser for address: lm-citibk
Register parser called by : HDFC Bank
Registered sms parser for address: am-hdfcbk
Traceback (most recent call last):
File "/Users/applegrew/Dropbox/Credit Expense/cclogger/cclogger/api_main.py", line 4, in <module>
from .bottle import run, default_app, debug, get
ValueError: Attempted relative import in non-package
エラーの上に表示されるメッセージは、 によってインポートされた同じパッケージ内のモジュールからのもの__init__.py
です。
api_main.py のコードは次のとおりです。
import re
import os
from .bottle import run, default_app, debug, get
from .common_util import date_str_to_datetime, UTCOffset, date_filter
#app = Bottle()
default_app().router.add_filter('date', date_filter)
from . import api, dev
@get('/index')
def index():
return "CCLogger API main live and kicking."
if dev:
debug(True)
run(reloader=True, port=9000)
else:
os.chdir(os.path.dirname(__file__))
application = default_app()
私はpython 2.7.1を持っています。
私は何を間違っていますか?https://github.com/applegrew/cclogger/tree/master/ccloggerで完全なコードを確認できます。