It's easier to iterate over a python file from a command prompt (cmd) .bat

Introduction

Hello. Wanko soba is a liberal arts student who attends a local public university.

In this article, I'll show you (as a reminder) how to run python from __cmd without having to rewrite it every time. By the way, this time we are dealing with .bat that __ batch file __.

When is it effective

In my case, of the module __Chainer Realtime Multi-Person Pose Estimator (hereinafter "CRMPE") __, centering on pose_detector.py, "Estimate the posture of the image of a person, and point and line. I wanted to repeat the content of "drawing and saving".

For university research (because the teacher is tolerant, please push your back even if the field deviates from the one in the laboratory) __ It became necessary to perform the same processing multiple times for a large amount of image data. That is the beginning of coding, which is called this article.

Like my case, I want to be able to repeat simple actions just by clicking __a specific file from the explorer (folder, etc.) screen! The batch file should work for those who say __.

What happened specifically


rem this is to apply pose_detector.py to images
call C:\Users\name\anaconda3\Scripts\activate.bat
C:\Users\name\anaconda3\python.exe C:\Users\name\CRMPE\pose_detector.py posenet models/coco_posenet.npz --img data/sth.png
pause
exit

(2) Since python3 works under the anaconda environment (it seems to be true), I had to move the batch file "activate.bat" in the Scripts of anaconda3 first. If you just have python under the C drive regardless of anaconda or something, you can start from the next line.

③ Write python.exe, then __half-width space __ (which is unexpectedly forgotten), and then write __pose_detector.py that you want to move this time and the details of the instruction __. It should be kept in mind that the contents of this __batch file are almost clean and copied to cmd as it is __, so the details of this area are the same as I thought to write in cmd in advance. You can write it.

④ By writing pause, you can prevent __cmd from disappearing as soon as the result is output __ (You can keep cmd open until you enter some key). In my case, when printing the coordinate data (matrix) of the points in the image while outputting the image, I want to check if the added python code is working __, and observe it by writing a pause. Got time.

⑤ Finally, close cmd with exit.

Finally

For programs that require fine debugging, batch files will play a role (although this is fairly simple and easy). Also, I wanted to be able to use it better ... (because I can write for statements)

(Aspiration) Do your best in research, job hunting, and preparation for the hospital exam.

Recommended Posts

It's easier to iterate over a python file from a command prompt (cmd) .bat
How to run a Python file at a Windows 10 command prompt
I tried running python etc. from a bat file
A memorandum to run a python script in a bat file
Python script to create a JSON file from a CSV file
How to get a string from a command line argument in python
Send a message from Python to Slack
Create a deb file from a python package
Call a command from Python (Windows version)
Send a message from Slack to a Python server
How to read a CSV file with Python 2/3
How to open a web browser from python
Import Excel file from Python (register to DB)
From file to graph drawing in Python. Elementary elementary
How to create a JSON file in Python
How to generate a Python object from JSON
Export Python3 version OpenCV KeyPoint to a file
Run a Python file from html using Django
Read line by line from a file with Python
I want to write to a file with Python
[It's not too late to learn Python from 2020] Part 2 Let's create a Python development environment
How to use NUITKA-Utilities hinted-compilation to easily create an executable file from a Python script
Parse a JSON string written to a file in Python
Try to make a command standby tool with python
Make a copy of a Google Drive file from Python
I want to randomly sample a file in Python
Steps from installing Python 3 to creating a Django app
[Python] Change standard input from keyboard to text file
From buying a computer to running a program with python
Consider a conversion from a Python recursive function to a non-recursive function
Procedure to exe python file from Ubunts environment construction
How to execute a command using subprocess in Python
[Python] How to call a c function from python (ctypes)
How to create a kubernetes pod from python code
[Python] Start a batch file from Python and pass variables.
Python --Read data from a numeric data file to find the covariance matrix, eigenvalues, and eigenvectors
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Execute command from Python
Execute command from python
Use Boto3 to retrieve over 1000 Prefixes from S3's file list
How to slice a block multiple array from a multiple array in Python
A Python script that saves a clipboard (GTK) image to a file.
How to run a Python program from within a shell script
Change the standard output destination to a file in Python
Summary from building Python 3.4. * From source to building a scientific computing environment
How to launch AWS Batch from a python client app
I want to start a lot of processes from python
How to import a file anywhere you like in Python
I want to send a message from Python to LINE Bot
Python> Read from a multi-line string instead of a file> io.StringIO ()
[Python] How to output a pandas table to an excel file
[Python] Read command line arguments from file name or stdin
When you want to hit a UNIX command on Python
I made you to execute a command from a web browser
(Translation) Native connection from Python to Hadoop file system (HDFS)
Extract the value closest to a value from a Python list element