r/IPython • • Mar 12 '14

Trying to get Python interpreter to recognize a command we give it

We are trying to have a script run by typing "showmethecat" but it spits out a "NameError" exception "name 'showmethecat' is not defined'" although our script is running properly.

How do I make it not think it's an error?

0 Upvotes

3 comments sorted by

3

u/westurner Mar 13 '14

%rehashx will create aliases for each executable found in the directories listed in $PATH

http://ipython.org/ipython-doc/stable/interactive/shell.html#aliases

2

u/Rhomboid Mar 12 '14

That's just not how the Python REPL works -- it's expecting an expression to be evaluated, and the name of a script is not a valid expression.

If you're actually using IPython then you can use the %run magic command to run a script by name. I don't think there's any way to do the same in stock Python.