Reputation: 2630
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
Upvotes: 0
Views: 612
Reputation: 653
Add this shebang to the top of your file: #!/usr/bin/env python
and remove the file extension.
Upvotes: 2
Reputation: 184071
Change the name of the script to no longer have the .py
extension.
Upvotes: 4