This README explains how to use the run.bat
script to set up and run Python projects on Windows systems. The script automates virtual environment creation, dependency installation, and script execution.
- Windows operating system
- Python 3.6 or higher installed and added to the system PATH
- Git (optional, for version control)
- Place
run.bat
in your Python project's root directory. - Ensure you have a
requirements.txt
file listing your project's dependencies. - Double-click
run.bat
or run it from Command Prompt:run.bat
- Checks for Python installation
- Creates a virtual environment (if it doesn't exist)
- Activates the virtual environment
- Upgrades pip to the latest version
- Installs required packages from
requirements.txt
- Runs the main Python script specified in the
MAIN_SCRIPT
variable
You can customize the following variables in run.bat
:
VENV_DIR
: Name of the virtual environment directory (default: "venv")REQUIREMENTS_FILE
: Name of the requirements file (default: "requirements.txt")MAIN_SCRIPT
: Name of your main Python script (default: "main.py")PYTHON_CMD
: Python command to use (default: "python")ADDITIONAL_ARGS
: Any additional arguments to pass to your Python script
If run.bat
doesn't work as expected:
- Run it from Command Prompt to see detailed output:
run.bat
- Ensure Python is installed and added to your system PATH.
- Check if you have necessary permissions to create directories and install packages.
- Verify that your
requirements.txt
and main Python script exist in the same directory asrun.bat
.
If run.bat
fails, you can set up the environment manually:
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
venv\Scripts\activate
- Install required packages:
pip install --upgrade pip pip install -r requirements.txt
- Run your main script:
python your_script.py
- The script creates a local virtual environment, ensuring your project's dependencies don't interfere with other Python projects.
- You can easily share your project by including
run.bat
andrequirements.txt
along with your Python scripts. - For any persistent issues, check your project's configuration or seek help from the project maintainers.