Python Forum
How do I run python scripts from any directory using Windows command prompt?
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I run python scripts from any directory using Windows command prompt?
#1
The default directory I'm usually in when I start up Windows command prompt is C:\Users\Moon\, which I'm content with.

I have some folders located in the directory C:\Users\Moon\AppData\Local\Programs\Python\Python36\
such as 'data scripts', deep learning scripts etc
They each contain different scripts.

I don't want to type in the whole directory nor change the directory, when I try to run from the command prompt:

python3.6 C:\Users\Moon\AppData\Local\Programs\Python\Python36\data scripts\data.py

python3.6 C:\Users\Moon\AppData\Local\Programs\Python\Python36\deep learning\NLP.py


Is there a way to shorten this to something like without changing directories?

python3.6" \deep learning\NLP.py"

python3.6 "\data scripts\....."

or maybe just shorten it in general?


Thank you.
Reply
#2
(Jun-14-2017, 12:32 AM)bigmit37 Wrote: I have some folders located in the directory C:\Users\Moon\AppData\Local\Programs\Python\Python36\
In part-1 look at a better location that the long default one.
Quote:I don't want to type in the whole directory nor change the directory, when I try to run from the command prompt:
In part-2 use of cmder can jump straight into any folder from file-explorer.
cmder also has a history of what is typed before(thisĀ i use all the time),just use arrow key.
Reply
#3
https://stackoverflow.com/questions/3701...-windows-7
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#4
That link is for older version of Python Ofnuts.
Python has changed the whole Windows installer for Python 3.6,PATH is added under installation.
That what i addresses in tutorial that i have linked to.
Reply
#5
The best solution is cmder as Snippsat suggests.
I started using it when he first suggested it to me. Very useful for very many things.
is can be called up simply with a right click in any directory and
python run immediately just by typing 'python' at the command line.
Highly recommended
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [SOLVED] [Windows] Change directory date? Winfried 2 595 May-11-2025, 04:24 PM
Last Post: Winfried
  Python GDB scripts for Fedora41 voidtrance 3 879 Apr-14-2025, 05:52 PM
Last Post: voidtrance
  How to communicate between scripts in python via shared file? daiboonchu 4 2,186 Dec-31-2024, 01:56 PM
Last Post: Pedroski55
  'pip' not recogmnized in windows prompt MaartenRo 1 1,241 Dec-21-2023, 09:05 AM
Last Post: menator01
  working directory if using windows path-variable chitarup 2 1,609 Nov-28-2023, 11:36 PM
Last Post: chitarup
  Trying to us python.exe from our network to run scripts cubangt 3 2,136 Aug-17-2023, 07:53 PM
Last Post: deanhystad
  What is the difference between Command Prompt and Sublimes yaoyao22 1 1,311 Jul-09-2023, 02:56 PM
Last Post: snippsat
  [SOLVED] [Windows] Right way to prompt for directory? Winfried 4 3,380 Jan-17-2023, 09:28 PM
Last Post: markoberk
  Open windows cmd prompt and run cmds with python Extra 3 4,077 Jul-14-2022, 06:07 AM
Last Post: Gribouillis
  Facing Problem while opening a file through command prompt vlearner 4 3,363 Jan-30-2022, 08:10 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020