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
  'pip' not recogmnized in windows prompt MaartenRo 1 400 Dec-21-2023, 09:05 AM
Last Post: menator01
  working directory if using windows path-variable chitarup 2 726 Nov-28-2023, 11:36 PM
Last Post: chitarup
  Trying to us python.exe from our network to run scripts cubangt 3 861 Aug-17-2023, 07:53 PM
Last Post: deanhystad
  What is the difference between Command Prompt and Sublimes yaoyao22 1 634 Jul-09-2023, 02:56 PM
Last Post: snippsat
  [SOLVED] [Windows] Right way to prompt for directory? Winfried 4 2,040 Jan-17-2023, 09:28 PM
Last Post: markoberk
  Open windows cmd prompt and run cmds with python Extra 3 1,439 Jul-14-2022, 06:07 AM
Last Post: Gribouillis
  Facing Problem while opening a file through command prompt vlearner 4 1,901 Jan-30-2022, 08:10 AM
Last Post: snippsat
  Running python scripts from github etc pacmyc 7 3,696 Mar-03-2021, 10:26 PM
Last Post: pacmyc
  Noob warning: trying to use pip to install pytest and pep8 in Command Prompt adifrank 4 5,308 Dec-20-2020, 04:23 AM
Last Post: adifrank
  Running Python in Command Prompt Anwar 3 3,077 Nov-15-2020, 03:15 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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