Reputation: 33
I recently installed Python 2.7.6 for 64 bit Windows7. I am trying to run few commands like cd, pwd etc and it is not running either on Windows Command Prompt, or Python Commnad Line. and i am getting the follwoing error:
>>cd Desktop
File "<stdin>", line 1
cd Desktop
^
I am also not able to execute any .py codes
(I cannot post image as i dont have enough reputations)
Upvotes: 0
Views: 900
Reputation: 8491
The Python interpreter doesn't accept shell/batch commands, but only valid python code. What you are trying to do in your example would translate like this in python:
import os
os.chdir("Desktop")
What you did is start the Python interpreter in interactive mode (or maybe did you start IDLE). To run a python script saved in a file from the command line, try
C:\Python33\python.exe your_script.py
(change the path to python.exe according to your installation). If you installed Python fully, you should be able to launch scripts by double clicking on .py
files.
If you use IDLE, see the official documentation. You can open a script from the menu and run it.
(Note that pwd
is not a valid command for the Windows shell either (use cd
without argument instead.)
Upvotes: 2