Issue
I tries to run python -m cProfile simple_test_script.py
. I'm on Windows 7, Python 2.7.10.
simple_test_script.py:
import numpy as np
from numpy.linalg import eigvals
def run_experiment(niter=100):
K = 100
results = []
for _ in xrange(niter):
mat = np.random.randn(K, K)
max_eigenvalue = np.abs(eigvals(mat)).max()
results.append(max_eigenvalue)
return results
some_results = run_experiment()
print 'Largest one we saw: %s' % np.max(some_results)
I get this error:
File "<ipython-input-13-6634cb53f497>", line 1
python -m cProfile simple_test_script.py
^
SyntaxError: invalid syntax
I read this documentation: https://docs.python.org/2/library/profile.html
(Use profile instead of cProfile if the latter is not available on your system.)
I tried profile instead of cProfile but the the same error. Any clues how i can call cProfile?
Solution
As satoru suggested, you would normally run a command like this in your shell/terminal/console (for everyday usage, these basically mean the same thing). However, you can also run it from inside IPython, e.g.:
%run -m cProfile simple_test_script.py
(the % symbol is part of the command, IPython has a few special commands that start with %)
Answered By - Marius
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.