d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Help With Python
Add Reply New Topic New Poll
Member
Posts: 14,925
Joined: Jan 3 2008
Gold: 135,879.75
Oct 21 2014 10:05pm
can someone walk me through how to run a python script?

I downloaded python and a friend wrote a script for me, but i'm not sure how to imput it.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 21 2014 10:09pm
iirc, just run this:

Code
python myfile.py


you can also refer to the documentation:
https://docs.python.org/2/faq/windows.html

This post was edited by carteblanche on Oct 21 2014 10:10pm
Member
Posts: 62,204
Joined: Jun 3 2007
Gold: 9,039.20
Oct 21 2014 10:29pm
Open Command Prompt or Terminal, change to directory to where you have the script saved,

In Windows:

cd C:\User\%username%\Desktop

In UNIX-like system:

cd ~/Desktop

In a UNIX-like environment you may also have to give it executable permissions

chmod a+x scriptname.py

Once you're in the same directory as the file, or you have the $PATH variable pointing to a directory the script is in, you will be able to run it below.

To run as-is:

python scriptname.py

To run the script interactively and work with things in real-time:

python -i scriptname.py

If you type python -h you can get more run-time options.

If you are using Windows and downloaded Python from the main website I highly recommend removing Python and downloading the Anaconda installer.
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Oct 22 2014 04:43am
I have to ask: how is this related to C/C++/C#?
Member
Posts: 62,204
Joined: Jun 3 2007
Gold: 9,039.20
Oct 22 2014 05:35am
Quote (KrzaQ2 @ Oct 22 2014 04:43am)
I have to ask: how is this related to C/C++/C#?


Python is babbys first C :^)

This post was edited by killg0re on Oct 22 2014 05:35am
Member
Posts: 14,925
Joined: Jan 3 2008
Gold: 135,879.75
Oct 23 2014 03:12pm
"python myfile.py" I did this. I get a syntax error. I checked m directory. I'm in Python27. So I put the myfile.py into Python27. It still doesn't work.

Member
Posts: 62,204
Joined: Jun 3 2007
Gold: 9,039.20
Oct 23 2014 04:01pm
Copy the code here too so we can figure out where your friend went wrong. In code brackets

This post was edited by killg0re on Oct 23 2014 04:01pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll