charlie_cat
charlie_cat

Reputation: 1850

running a python script from the terminal

I have python installed but get an error when I want to run ez_setup.py. I am following: http://docs.python-guide.org/en/latest/starting/install/win/

So I can install the setuptools and pip.

Please see the screenshot of my python terminal with the script. the script is located in the same folder as python.exe

enter image description here

Upvotes: 0

Views: 2800

Answers (2)

devhallo
devhallo

Reputation: 367

There are multiple ways you can run a python script from the python interpreter:

Direct call:

you can directly call the python interpreter with the script path as argument

C:\path\to\python.exe mycode.py

Import:

If the script is in the current working directory or in python path, you could import the script

import mycode

Note that the script will be executed in it own namespace in this case.

execfile:

You can use execfile to execute the script

execfile("C:\path\to\mycode.py")

Upvotes: 0

user1907906
user1907906

Reputation:

Run it like this:

C:\Users\CatGirl> python.exe ez_setup.py

python.exe is the Python executable which can take the name of a script as an argument. In your case this argument is ez_setup.py.

Upvotes: 2

Related Questions