directorys

This is the place for queries that don't fit in any of the other categories.

directorys

Postby sprocket » Fri Feb 22, 2013 9:08 am

hi guys im relativly new to programming i tried learning python a few months back but gave up as you may have guessed i am now trying again. I wasent sure where to post this so i thught to post it here. I am struggling with directorys in command prompt to open .py files i can make it work but i seem to be doing a lot of typing plz can someone show me how to do it properly this is how command prompt looks when i do it...

C:\Users\Sprocket>C:\Users\Sprocket\pythonscripts\(scriptname).py

If anyone can help me it would be greatly apriciated :D :D :D :D
sprocket
 
Posts: 3
Joined: Fri Feb 22, 2013 8:46 am

Re: directorys

Postby metulburr » Fri Feb 22, 2013 9:32 am

I am struggling with directorys in command prompt to open .py files i can make it work but i seem to be doing a lot of typing plz can someone show me how to do it properly

What are you trying to open it with? To be honest i havent used windows in years so i forgot the default editor for windows and/or its command to open a file with it.

C:\Users\Sprocket>C:\Users\Sprocket\pythonscripts\(scriptname).py

this is your current command prompt location
Code: Select all
C:\Users\Sprocket


this is apparently the path to the python script
Code: Select all
C:\Users\Sprocket\pythonscripts\(scriptname).py


If your trying to change to the directory of the python script, you need to execute:
Code: Select all
cd pythonscripts


at that point your prompt should read:
Code: Select all
C:\Users\Sprocket\pythonscripts>


executing:
Code: Select all
dir

will list out the files and directories in that directory, which scriptname.py should be listed

also have you read through this?
we will be moving to python-forum.io on October 1 2016
more details here
User avatar
metulburr
 
Posts: 2228
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: directorys

Postby ichabod801 » Fri Feb 22, 2013 2:03 pm

If you are using version 3.3 or later, you should check out the Python launcher for Windows.
Due to the reasons discussed here we will be moving to python-forum.io on October 1st, 2016.
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
ichabod801
 
Posts: 687
Joined: Sat Feb 09, 2013 12:54 pm
Location: Outside Washington DC

Re: directorys

Postby sprocket » Fri Feb 22, 2013 3:34 pm

What are you trying to open it with?


I am opening it through command prompt (the windows defult command line) with the standard python 3.3 compiler (not the interactive one) but when i did the install of python i chose for any file ending .py to be run with the python compiler if that is any help
sprocket
 
Posts: 3
Joined: Fri Feb 22, 2013 8:46 am

Re: directorys

Postby snippsat » Fri Feb 22, 2013 5:40 pm

C:\Users\Sprocket>C:\Users\Sprocket\pythonscripts\python (scriptname).py

To use python anywhere from cmd(command line) you need to make sure that Environment Variables are set to your python version.
To PATH add ;C:\python33\;C:\python33\scripts;
Restart.

Test it out in cmd.
Code: Select all
C:\>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

Of course 3.3 for for you if that the version you use.

So if i want to run i file have under root C:\,let`s call it something.py
Code: Select all
C:\>python something.py
python: can't open file 'something.py': [Errno 2] No such file or directory

No do i not have i file called something.py under root C:\,so i am happy with that output ;)
If i had that file under root C:\ python would run it.
We will be moving to python-forum.io on October 1 2016
User avatar
snippsat
 
Posts: 1251
Joined: Thu Feb 21, 2013 12:04 am


Return to General Coding Help

Who is online

Users browsing this forum: ichabod801, roadrage and 6 guests