简体   繁体   中英

Start a virtualenv inside a shell script

I'm working on a Python project that's wrapped in a virtualenv. I'd like to have a script that does all the "footwork" of getting set up as soon as I clone my git repo -- namely make the virtualenv, download my requirements, and stay in the virtualenv after exiting . However, once the shell script finishes, I'm no longer in my virtualenv, since the changes it makes to its shell don't propagate to mine.

How can I have the virtualenv "stick" to the parent shell that ran the script?

Use a function instead of a separate script. A function executes in the context of your current shell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM