line_profiler 并且 kernprof 无法从 pip 和 repro 安装
line_profiler and kernprof does not work installed from pip and repro
我已经尝试了建议的方法。在最简单的代码中,我得到了其他人提到的熟悉的错误。错误是:
@profile
NameError: name 'profile' is not defined
关于最小代码:
@profile
def hello():
print('Testing')
hello()
从命令行:
kernprof -l hello.py
我已经导入 future
我什至从我的 virtualenv 之外的发行版安装了。这是以前的 suggestion,导入未来的模块也是如此。
所以
import future
import cProfile
@profile
def hello():
print('Testing')
hello()
也给出同样的错误。我无法让此行分析器与 pip 一起使用,甚至无法从原始存储库中获取。我的版本是:
pip 8.1.2
python 2.7
我修复了这个问题,我从 https://github.com/rkern/line_profiler 克隆代码并重建,然后从二进制安装位置调用 kernprof。
您可以在 python 文件的开头添加以下代码段:
import line_profiler
profile = line_profiler.LineProfiler()
我已经尝试了建议的方法。在最简单的代码中,我得到了其他人提到的熟悉的错误。错误是:
@profile
NameError: name 'profile' is not defined
关于最小代码:
@profile
def hello():
print('Testing')
hello()
从命令行:
kernprof -l hello.py
我已经导入 future
我什至从我的 virtualenv 之外的发行版安装了。这是以前的 suggestion,导入未来的模块也是如此。
所以
import future
import cProfile
@profile
def hello():
print('Testing')
hello()
也给出同样的错误。我无法让此行分析器与 pip 一起使用,甚至无法从原始存储库中获取。我的版本是:
pip 8.1.2
python 2.7
我修复了这个问题,我从 https://github.com/rkern/line_profiler 克隆代码并重建,然后从二进制安装位置调用 kernprof。
您可以在 python 文件的开头添加以下代码段:
import line_profiler
profile = line_profiler.LineProfiler()