A
A
Allex2020-07-04 12:31:59
Python
Allex, 2020-07-04 12:31:59

How to make python script its own command for windows command line?

Good afternoon. I have some working python script that I can run from its location directory by typing on the command line: "python <script name>.py".
What needs to be done so that I can run it as a command (giving it any name I want) from any directory?
Thanks in advance for any help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan, 2020-07-04
@Allex

Under linux, specify at the beginning of the file, for example #!/usr/bin/env python3
But before that, make the script file executable by setting the special attribute chmod +x script.py

S
soremix, 2020-07-04
@SoreMix

Add the path to the script to the PATH variable
Or drop the file into the Z:\PythonXX\Scripts\ folder, it should already be in the PATH variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question