#π What does the py command actually do in Windows Command Prompt?
22 messages Β· Page 1 of 1 (latest)
@paper peak
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
It's a separate executable that eventually calls (some version of) python. Very handy.
(also, not sure what you mean by "is a path")
in the installation theres a box that you can check to make the word python in cmd prompt as a path to like python.exe
Sure, that works the same way, there's a py.exe in one of the folders in your PATH
(that's how all console commands work - when you type a command, unless it is built into your terminal like cd, its name is looked up in PATH and whatever executable found is ran)
you can also type in cmd:
where python
where py
to see where those .exe files actually are
probably didnt add python to path
should I? i've heard its bad for multiple versions
I'll always have my "main" Python version on PATH so I can install libraries that have their own commands (like black, or ipython, or pyinstaller) and they'll just work.
I don't think it's bad as long as you know what you're doing
You can still access other versions with py
You also don't need to do that though
sorry but what is a path
is it the path to a file?
With the "py.exe" command you can execute a particular version of python that you have previously installed. For example, if you have Python 3.10 installed and later install Python 3.12 alongside it, you can use the command "py.exe -3.10 my_script.py" to have my_script.py run under the 3.10 interpreter, even if Python 3.12 is the one that runs by default when you use "python.exe". This is useful if my_sctipt.py has dependencies on libraries that are installed under 3.10 but not 3.12.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.