Python Forum
Can't get .py to run on Win10 command line
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't get .py to run on Win10 command line
#1
Hi,

I'm trying to run my python script from a Windows 10 command prompt (batch file).

It works if I'm in the correct directory of where my python script resides (outside of python install dir); but not if I'm in a different directory.

My python 3.6.1 install is here:  C:\Users\John\AppData\Local\Programs\Python\Python36\python.exe
My python script is here:  C:\Python_TestScript\runtime\jm_run.py

If I change directory to C:\Python_TestScript\ and try to run I get:
Quote:C:\Python_TestScript>C:\Users\John\AppData\Local\Programs\Python\Python36\python.exe C:\Python_TestScript\runtime\jm_run.py

C:\Python_TestScript>

However, if I change to the directory in which the script resides C:\Python_TestScript\runtime\  it works as expected:
Quote:C:\Python_TestScript\runtime>C:\Users\John\AppData\Local\Programs\Python\Python36\python.exe C:\Python_TestScript\runtime\jm_run.py
Creating summariser <summary>
Created the tree successfully using C:\!!PythonTest\KickOffTest\test.jmx
Starting the test @ Tue Nov 07 14:34:14 GMT 2017 (1510065254649)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =     10 in 00:00:02 =    4.3/s Avg:   376 Min:   104 Max:  1591 Err:     0 (0.00%)
Tidying up ...    @ Tue Nov 07 14:34:17 GMT 2017 (1510065257651)
... end of run
***** DONE *****

C:\Python_TestScript\runtime>


Any ideas?  This seems a bit odd to me.

Cheers,
J
Reply
#2
Your environment path path is not set up correctly.
This is a common problem, and has to do with installation option.
During install, one of the options is to add python to your environment path.

The easiest way to overcome this is  to re-install, making sure you select the path option
while at it, make sure installation location is c:\Pythonxx where xx is version
Reply
#3
(Nov-07-2017, 02:36 PM)jonesin1974 Wrote: My python 3.6.1 install is here:  C:\Users\John\AppData\Local\Programs\Python\Python36\python.exe
That long default path is just annoying,
uninstall and follow Python 3.6 and pip installation under Windows, part-2.
Reply
#4
Hi guys,

Many thanks for your help.  I've re-installed and that seems to have fixed my issue.  Thanks for the guide as well.  There were some options I would normally have overlooked including adding the install dir to the Path.

Cheers,
J
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Command line argument issue space issue mg24 5 1,280 Oct-26-2022, 11:05 PM
Last Post: Yoriz
  accept command line argument mg24 5 1,241 Sep-27-2022, 05:58 PM
Last Post: snippsat
  Accessing varying command line arguements Rakshan 3 2,008 Jul-28-2021, 03:18 PM
Last Post: snippsat
  Where does pip auto install on Win10 with py 3.9.4? Fran_3 4 3,454 May-05-2021, 03:47 PM
Last Post: snippsat
  How to input & output parameters from command line argument shantanu97 1 2,507 Apr-13-2021, 02:12 PM
Last Post: Larz60+
  Passing List of Objects in Command Line Python usman 7 3,090 Sep-27-2020, 03:45 PM
Last Post: ndc85430
  Compiling on win10 ebolisa 1 1,725 Sep-04-2020, 04:39 PM
Last Post: ebolisa
  Taking Multiple Command Line Argument Input bwdu 6 3,928 Mar-29-2020, 05:52 PM
Last Post: buran
  python 3 from command line Dixon 1 1,966 Mar-01-2020, 08:35 PM
Last Post: snippsat
  Running linux command line apps... dbrdh 0 1,622 Jan-30-2020, 01:14 PM
Last Post: dbrdh

Forum Jump:

User Panel Messages

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