Running python script inside ipython

前端 未结 5 983
无人及你
无人及你 2020-12-04 08:08

Is it possible to run a python script (not module) from inside ipython without indicating its path? I tried to set PYTHONPATH but it seems to work only for modules. I would

5条回答
  •  难免孤独
    2020-12-04 08:29

    In python there is no difference between modules and scripts; You can execute both scripts and modules. The file must be on the pythonpath AFAIK because python must be able to find the file in question. If python is executed from a directory, then the directory is automatically added to the pythonpath.

    Refer to What is the best way to call a Python script from another Python script? for more information about modules vs scripts

    There is also a builtin function execfile(filename) that will do what you want

提交回复
热议问题