A memorandum to run a python script in a bat file

In windows environment

・ If you make a bat file, you do not have to mess with the black screen as much as possible. -It is necessary to specify the python path in the environment variable in advance.

Create and place a bat file (.bat) in any folder

cd /d %~dp0

python test.py
pause

Make arbitrary processing into a python file (test.py)

from sklearn.datasets import load_iris
import pandas as pd
import seaborn as sns

iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['target'] = iris.target
img1 = sns.lmplot('sepal length (cm)','sepal width (cm)',data=df,hue='target')
img1.savefig("out_img1/img1.png ")
img2 = sns.pairplot(df, hue="target")
img2.savefig("out_img2/img2.png ")

This time, I prepared subfolders named out_img1 and 2 in any folder. The output is output to the specified subfolder.

Put the bat file and py file in the same folder and execute bat

that's all

Recommended Posts

A memorandum to run a python script in a bat file
Run the Python interpreter in a script
How to run a Maya Python script
Create a shell script to run the python file multiple times
How to create a JSON file in Python
Create a shortcut to run a Python file in VScode on your terminal
Parse a JSON string written to a file in Python
Create a plugin to run Python Doctest in Vim (2)
Create a plugin to run Python Doctest in Vim (1)
I want to randomly sample a file in Python
Python script to create a JSON file from a CSV file
Run a Python file with relative import in PyCharm
Run a multi-line script in a PDB
Create a binary file in Python
Run a simple algorithm in Python
Assigned scaffolding macro in Python script file to F12 key
How to run a Python file at a Windows 10 command prompt
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
How to import a file anywhere you like in Python
Script python file
How to pass arguments to a Python script in SPSS Modeler Batch
I made a script in Python to convert a text file for JSON (for vscode user snippet)
Pin current directory to script directory in Python
Convert psd file to png in Python
Sample script to trap signals in Python
How to get a stacktrace in python
I wrote a function to load a Git extension script in Python
I wrote a script to extract a web page link in Python
[V11 ~] A memorandum to put in Misskey
[GPS] Create a kml file in Python
Script to create a Mac dictionary file
Let's run a Bash script in Java
I made a script in python to convert .md files to Scrapbox format
A memorandum because I stumbled on trying to use MeCab in Python
I made a program to check the size of a file in Python
Run a Python script from a C # GUI application
How to read a CSV file with Python 2/3
Create a GIF file using Pillow in Python
How to clear tuples in a list (Python)
To execute a Python enumerate function in JavaScript
How to embed a variable in a python string
Type Python scripts to run in QGIS Processing
I want to create a window in Python
From file to graph drawing in Python. Elementary elementary
How to run some script regularly in Django
A clever way to time processing in Python
Steps to develop a web application in Python
To add a module to python put in Julialang
How to notify a Discord channel in Python
Export Python3 version OpenCV KeyPoint to a file
Call a Python script from Embedded Python in C ++ / C ++
How to run Leap Motion in non-Apple Python
Run a Python file from html using Django
[Python] How to draw a histogram in Matplotlib
Create a MIDI file in Python using pretty_midi
I want to write to a file with Python
How to read a file in a different directory
Run a python script from excel (using xlwings)
Sample to put Python Kivy in one file