OldGuy
OldGuy

Reputation: 53

Python Scripts on Windows 10

I am a new python user. I need to run scripts written by (remote) coworkers.

My first install of Python is 3.5.0.rc1. It was installed on a Windows 10 machine using the python webinstaller.

On installation, I told the installer to add all Python components, and to add Python to the PATH. I authorized python for all users.

I can load and access Python through the command line. It will respond to basic instructions (>>> 1+1 2).

However, I do not get the expected response from some basic commands (eg, >>>import os followed by >>>print os.getcwd() results in a syntax error rather than in a print of the directory containing the python executable).

Further, I can not get python to execute scripts (eg. >>>python test.py). This results in a syntax error, which seems to point to various places in the script file name. I have tried a quick search of previous questions on StackOverfow, and can't seem to find discussion of what seems to be a failure on this basic of level.

Perhaps I have not loaded all the necessary python modules, or is it something else that I'm missing

Upvotes: 3

Views: 7038

Answers (2)

Gaurav Kochar
Gaurav Kochar

Reputation: 1

in python3 print is replaced by print() you can use this

Upvotes: 0

Marcus Müller
Marcus Müller

Reputation: 36352

I can load and access Python through the command line. It will respond to basic instructions (>>> 1+1 2).

This means Python was, in principle, correctly installed. Congratulations!

Further, I can not get python to execute scripts (eg. >>>python test.py)

The >>> indicate you're trying to run this from the python prompt. That's wrong. You need to run python.exe with the script file as argument from the windows prompt (cmd).

>>>print os.getcwd() results in a syntax error

That's because you're using python3 and print expression is python2 syntax that is now incorrect. You will either need to do

print(os.getcwd())

or install python2.

Upvotes: 3

Related Questions