Reputation: 368
I'd like to convert my python script to a module that can be called from the commandline. Kind of like pytest or something.
For instance, my script is named egscript.py
. I have to run the script like this, >python3 egscript.py [commandline args]
What I want instead is to be able to do it like this,
>egscript [commandline args]
How can I achieve this?
Upvotes: 1
Views: 893
Reputation: 6483
As you can see in this link, you can use:
C:\> assoc .py=Python
C:\> ftype Python="C:\python27\python.exe %1 %*"
I suggest you to see the link I put before. If you want to run it as a package like pip install egscript
and then use egscript
, you have to create a package to upload it into the Python Package Index(PyPy). To make that posible, follow the steps in these links: Build Your First pip Package, Packaging Python Projects.
Upvotes: 1
Reputation: 526
You could set an alias in your .bashrc
or .zshrc
file
alias egscript="python3 /path/to/egscript.py"
Or you could turn it into an executive using something like pyinstaller, and then you can run the script like ./egscript
Upvotes: 1