Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Run python script like a Linux command

I want to run my python function in console like this:

my_function_name

at any directory, I tried to follow arajek's answer in this question: run a python script in terminal without the python command

but I still need to call my_function_name.py to make it work. If I call only my_function_name, the console will inform me command not found . I also tried to add a symbolic link with this answer: Running a Python Script Like a Built-in Shell Command but it failed

sudo ln -s my_function_name.py /home/thovo/test/my_function_name

ln: failed to create symbolic link ‘/home/thovo/test/my_function_name/my_function_name.py’: File exists

Answer*

Draft saved
Draft discarded
Cancel
1
  • I have never thought to remove the .py extension will make it work. It may be not quite right from my point of view only but it really worked. Thank you a lot! I will mark this answer as correct after few minutes. Commented Feb 8, 2015 at 19:28

default

AltStyle によって変換されたページ (->オリジナル) /