进入ipython自动引入numpy

https://stackoverflow.com/questions/11124578/automatically-import-modules-when-entering-the-python-or-ipython-interpreter

https://stackoverflow.com/questions/52512650/python-path-and-juptyter-notebook-on-windows

https://stackoverflow.com/a/11124846/19253199

首先找到ipython_config.py文件

ipython profile create

如果已经有了就用下面的定位

ipython profile locate

然后增加这一行

c.InteractiveShellApp.exec_lines = ['import numpy as np', 'print("import numpy as np")']

在这里插入图片描述
结果
在这里插入图片描述

更多请看ipython_config的用法请看
https://ipython.readthedocs.io/en/stable/config/intro.html#example-configuration-file

方法2:启动脚本放startup文件夹里

ipython profile locate找到文件夹。里面有个profile_default,再往里面有个startup文件夹。把脚本放这里

import numpy as np
import scipy, os, sys
from scipy.io import mmread, mmwrite
print("Using startup.py at ", __file__)
print("import numpy, scipy and mmread, mmwrite")
os.chdir("E:/Dev/tiPBD/")
sys.path.append(os.getcwd())
print("Current working directory is:", os.getcwd())

在这里插入图片描述

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值