在ipython中运行python脚本 [英] Running python script inside ipython

查看:83
本文介绍了在ipython中运行python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从ipython内部运行python脚本(而不是模块)而不指示其路径?我试图设置PYTHONPATH但它似乎只适用于模块。
我想执行

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 like to execute

%run my_script.py

,不在包含该文件的目录中。

without being in the directory containing the file.

推荐答案

从my_script.py目录中你可以做到:

from within the directory of "my_script.py" you can simply do:

%run ./my_script.py

这篇关于在ipython中运行python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆