| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 149613 | 2021-02-27 06:43:00 | DOS batch file question | Billy (6701) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 1475265 | 2021-02-27 06:43:00 | I have a data file, called myInput, in a directory called c:MyProject I have a python program, called myProcess, also in c:MyProject I want to run the batch file, also stored in c:Myproject The environment variable is set to point to c:\python32 which is where my python lives DOS BATCHFILE python process.py -i myInput.txt dir /w pause ERROR MESSAGE: When I run my batch file I get the error message "c: python was not found" The environment variable should have told it where to look for python surely? NOTE: If I copy MY DATA, PROGRAM and my BATCH file into c:\python32 directory it works! But I don't want to do that. Thanks in advance SYSTEM: W10 |
Billy (6701) | ||
| 1475266 | 2021-02-27 06:55:00 | I found that this works... BATCHFILE c:\python32\python.exe process.py -i myInput.txt dir /w pause BUT it still doesn't explain why my environment variable doesn't work! |
Billy (6701) | ||
| 1475267 | 2021-02-27 08:52:00 | What environment variable is set to c:\python? If its pythonhome that doesnt help with Executing python from anywhere. You need to add c:\python to the PATH environment variable |
psycik (12851) | ||
| 1475268 | 2021-02-27 21:05:00 | Also make sure that the Python path is set under System Variables and NOT User Variables. | chiefnz (545) | ||
| 1475269 | 2021-02-28 19:55:00 | path C:\python32 :) smiley face is optional in DOS Better way(?) would be to add this to the start bat file CD\ CD c:\python32 |
1101 (13337) | ||
| 1475270 | 2021-02-28 19:57:00 | BUT it still doesn't explain why my environment variable doesn't work! from a cmd prompt, run path see whats actually in there |
1101 (13337) | ||
| 1475271 | 2021-02-28 22:04:00 | path C:\python32 :) smiley face is optional in DOS Better way(?) would be to add this to the start bat file CD\ CD c:\python32 I don't disagree with that, it is a "workaround" to the problem... the whole point behind "system paths" is to be able to "point the OS" to the correct locations for executable files/programmatic access etc... having to constantly add lines of "code" to a file to get to a path is not an efficient practice. Environment variables exist because "standard paths" for programming languages/compilers etc became "normal" over time. |
chiefnz (545) | ||
| 1 | |||||