How to Run Python in CMD?

Let's get into it pretty quick - you tried running ls command in your Python shell but noticed the same did not work. The problem you are likely to encounter is "ls is not defined" or "invalid syntax".

Note- ls command list

Cause- In the first place, you are facing this problem because ls is the command for Mac terminal and not Python shell.

It is very likely you have misunderstood the command use-case. The same is meant to work not in Python Shell but Command Prompt or Terminal (as you call it in Mac).


Try running the same in Terminal or Command Prompt. Below is the screenshot of the same.


cd desktop is Windows command to change active directory to desktop. dir is the ls equivalent in command prompt.


Type python in command prompt or Terminal in Mac and the result should look something like-


If typing �Python� leads to error, it is quite likely that you have not configured it with CMD. 

Here�s how to do it-

Right click on Computer and go to Properties.


Now click on advance system settings and then Environment Variables.


Click on environment variables, then scroll to the field where it says path. If it does not point to Python, edit path.

From My Computer, located the Python folder. Mine is located right inside the C drive.


From the address bar, copy the address and paste it in the path tab.

Overall, path field should finally look like-


Exit any running command terminals and try running it again � also, always run as an admin. 
Type in python.

This should load a few stats for your python.


Note, you can assign environment variables the same way even on your python hosting VM, provided you have Windows Server installed to it.

Was this answer helpful? #11 #10
 

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Related Questions

Submit your Query

  • I'm not a robot

Browse by ServicesBrowse by Services

Resource Library

What is Cloud Computing

Understand the term cloud computing, the ongoing trend, its playing field, future growth and how industry...

Myths about Cloud Computing

Cloud computing, in the recent years, has become a subject of significant discussion among the industry experts.

Download Now

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Submit Query

Please fill in the form below and we will contact you within 24 hours.