I have an application that is primarily written in python. I wish to make and use a virtual environment with all the required packages. In Linux, this was quite easy. Here is my shell script to set up the virtual environment
#!/bin/bash
#It is best practice to create virtual environments for projects that require many packages installed
python3 -m venv ./python_environment #Creates a new virtual environmnet in PWD
source ./python_environment/bin/activate #swithces to our new virtual environment
#Now we can install the needed packages using pip
python3 -m pip install --upgrade pip
pip install numpy opencv-python pillow imutils
And here is my script to launch the application
#!/bin/bash
#This is a wrapper that launches program
source ./python_environment/bin/activate # Uses custom python envionment in PWD
PYWRAP=$(cat <<EOF
import tagging
import tagging.tagger_controller
tagging.tagger_controller.start()
EOF
)#BASH Variable to pass to python
python3 -c "$PYWRAP" #Executes the python wrapper
When I try to do this for Windows, the scripts are not as elegant. setup.bat runs but I noticed that some of the packages didn't install
python -m venv python_environment
python_environment\Scripts\activate.bat
python -m pip install --upgrade pip
pip install numpy opencv-python pillow imutils
launcher.bat only activates the environment, it doesn't start the app. You may also note that this script calls a .py file, this is less than ideal but I don't know how to embed a few lines of python into a batch file, like I did in Linux.
python_environment\Scripts\activate.bat
python main.py
Please let me know what you think...