Python Forum
Python related simple shell scripting issue - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Python related simple shell scripting issue (/thread-15530.html)



Python related simple shell scripting issue - Larz60+ - Jan-20-2019

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



RE: Python related simple shell scripting issue - mlieqo - Jan-20-2019

Maybe just instead of:
. deactivate
try:
deactivate



RE: Python related simple shell scripting issue - Larz60+ - Jan-20-2019

That works fine.
Thank You!


RE: Python related simple shell scripting issue - DeaD_EyE - Jan-20-2019

I guess deactivate is created as alias.


RE: Python related simple shell scripting issue - Larz60+ - Jan-20-2019

It is, when executing activate