Python Forum
How do I run python scripts from any directory using Windows command prompt? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How do I run python scripts from any directory using Windows command prompt? (/thread-3688.html)



How do I run python scripts from any directory using Windows command prompt? - bigmit37 - Jun-14-2017

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.


RE: How do I run python scripts from any directory using Windows command prompt? - snippsat - Jun-14-2017

(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.


RE: How do I run python scripts from any directory using Windows command prompt? - Ofnuts - Jun-15-2017

https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7


RE: How do I run python scripts from any directory using Windows command prompt? - snippsat - Jun-15-2017

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.


RE: How do I run python scripts from any directory using Windows command prompt? - Larz60+ - Jun-15-2017

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