Python Forum

Full Version: Python related simple shell scripting issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a whole bunch of old projects that were created without virtual environment.
many of them use the same packages, so I thought I'd create a bash script to:
  1. Create a virtual environment
  2. Activate the environment
  3. Create a requirements.txt file for the packages
  4. Run pip to install the packages
  5. deactivate the virtual environment
  6. Move to next project and do it all again

Everything works until I get to step 5 (deactivate) The command executes, but when the script exits, the virtual environment is still running
My bash shell programming skills are very rusty, so what am I doing wrong?

script:
#!/bin/bash
python -m venv venv
. ./venv/bin/activate
cat > ./venv/requirements.txt << EOM
lxml
requests
pylint
BeautifulSoup4
selenium
EOM
pip install -r ./venv/requirements.txt
cp -r ../../../A-D/D/drivers/chromedriver ./venv/bin/chromedriver
cp -r ../../../A-D/D/drivers/geckodriver  ./venv/bin/geckodriver
. deactivate
Maybe just instead of:
. deactivate
try:
deactivate
That works fine.
Thank You!
I guess deactivate is created as alias.
It is, when executing activate