python - 如何在 ipython 启动时将目录添加到 sys.path

标签 python ipython

环境:

  • windows 7 英文 32 位
  • python 2.7.3
  • ipython 0.13.1

我试试配置:

ipython -i -c "import sys; sys.path.append('path_name')"

但是好像不行。
那么正确的解决方法是什么?

或者如何在 ipython 启动时将当前目录添加到 sys.path?
谢谢。

最佳答案

稍微跟进一下Honghe.Wu的回答。

有人可能想补充:

c.InteractiveShellApp.exec_lines = [
'import sys; sys.path.append("/absolute/path/")']

到ipython_config.py添加任意目录。

此外,如果您是 ipython 的新手(就像我一样),您需要先创建标准配置文件,因此 ipython_config.py 实际上存在。所以你需要:

ipython profile create

可以通过

找到配置目录
ipython locate

最佳 S

关于python - 如何在 ipython 启动时将目录添加到 sys.path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15137985/

相关文章:

python - 使用 numpy 按条件删除列表中的列表

python - 如何使这个舍入函数更快?

matplotlib - ipython notebook pylab inline - matplotlib.pyplot - 如何用滚动条显示绘图?

python - 带有 osx 后端的 Matplotlib 3.0

python - h5py - 将对象动态写入文件?

javascript - 没有编码为 UTF-8 或 base64 的 websocket 二进制数据

python - Django 二进制或 BLOB 模型字段

python-3.x - 名称错误: name 'get_ipython' is not defined

IPython 在选项卡完成时崩溃

python - IPython 需要哪些硬件规范?