コンソールからモジュールを実行しようとしています。私のディレクトリの構造はこれです:
私はモジュールを実行しようとしていますp_03_using_bisection_search.pyから、problem_set_02使用してディレクトリ:
$ python3 p_03_using_bisection_search.py内部のコードp_03_using_bisection_search.pyは次のとおりです。
__author__ = 'm'
from .p_02_paying_debt_off_in_a_year import compute_balance_after
def compute_bounds(balance: float,
                   annual_interest_rate: float) -> (float, float):
    # there is code here, but I have omitted it to save space
    pass
def compute_lowest_payment(balance: float,
                           annual_interest_rate: float) -> float:
    # there is code here, but I have omitted it to save space
    pass    
def main():
    balance = eval(input('Enter the initial balance: '))
    annual_interest_rate = eval(input('Enter the annual interest rate: '))
    lowest_payment = compute_lowest_payment(balance, annual_interest_rate)
    print('Lowest Payment: ' + str(lowest_payment))
if __name__ == '__main__':
    main()私はp_02_paying_debt_off_in_a_year.pyコードが含まれている関数をインポートしています:
__author__ = 'm'
def compute_balance(balance: float,
                    fixed_payment: float,
                    annual_interest_rate: float) -> float:
    # this is code that has been omitted
    pass
def compute_balance_after(balance: float,
                          fixed_payment: float,
                          annual_interest_rate: float,
                          months: int=12) -> float:
    # Omitted code
    pass
def compute_fixed_monthly_payment(balance: float,
                                  annual_interest_rate: float) -> float:
    # omitted code
    pass
def main():
    balance = eval(input('Enter the initial balance: '))
    annual_interest_rate = eval(
        input('Enter the annual interest rate as a decimal: '))
    lowest_payment = compute_fixed_monthly_payment(balance,
                                                   annual_interest_rate)
    print('Lowest Payment: ' + str(lowest_payment))
if __name__ == '__main__':
    main()次のエラーが発生します。
ModuleNotFoundError: No module named '__main__.p_02_paying_debt_off_in_a_year'; '__main__' is not a packageこの問題の解決方法はわかりません。__init__.pyファイルを追加しようとしましたが、まだ機能しません。
eval(input(...ビットは2to3によって提案されたに違いない。今日はそれをしてもらいました。目立たない提案に従っていないのがうれしい
                

eval(input...です。おそらく素晴らしいアイデアではありません。任意のコード実行の機会を開くのではなく、単に解析するだけです。