Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing PY files from Interpreter or IDE

Status
Not open for further replies.

jerjim

Programmer
Jan 4, 2001
85
PH
Hi to everyone:

I have spent about two hours poring through the documentation to solve my problem but I couldn't find anything.
And so to save time, I am posting this question here.

I have a Windows 2000 system with a NTFS formatted 40Gig hard disk.
I installed Python 2.3.4 in folder C:\Python23.
I also installed MySql in folder C:\MySql
I want to store my source files (.PY) and MySql database in other folders say C:\P1, C:\P2, etc.
When I am in the Python Interpreter or PYthon IDE, how do I execute my PY files in C:\P1 or any folder for that matter.
I keep getting error messages about invalid syntax.

Thanks again in advance.
 
This looks as though you haven't added python to the system path.

To do this, you need to add c:\Python23 to the PATH environment variable.

Go:

Start > Settings > Control Panel
Open (double click) System
Find the Advanced tab, click on Environment Variables.

In the Systems Variables list, click on PATH, then click Edit

At the end of the string type ;C:\Python23.

OK out of everything and restart.

If this is not the case, then in Windows Explorer

Tools > Folder Options > File Types tab and check if your system recognises .py as python files make sure that it is linked to a python executable.

As something else to check, if you open a command prompt and type:

C:\python23\python C:\P1\script.py

do you get output?

If you are trying to run them in IDLE, open the file, you should get the module window - just press F5 here and it should work.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top