bash - can't setup virtualenv (and cd) from script?
by scottmusician from LinuxQuestions.org on (#5QW2H)
Hi all,
I'm trying to create a little bash script that:
(a) switches to a directory (~/myapp)
(b) creates a python virtualenv (eg. myapp-env)
(c) activates the virtualenv , so that my shell is ready to start operating in this new, isolated virtual python environment.
I've a neat bash one-liner that does this, and works fine when just punched into the command line:
Quote:
but I can't seem to add this into any scripts - presumably because the script executes in a separate child process that doesn't inherit my local (~/.bashrc) stuff?
How can I convert this to a script? Alternatively, I'd be happy to convert the above one-liner to a variable, and execute that (I'm quite new to bash so I'm not even sure how to do that! But I could work it out relatively easily, I think).
Thanks for your help!
I'm trying to create a little bash script that:
(a) switches to a directory (~/myapp)
(b) creates a python virtualenv (eg. myapp-env)
(c) activates the virtualenv , so that my shell is ready to start operating in this new, isolated virtual python environment.
I've a neat bash one-liner that does this, and works fine when just punched into the command line:
Quote:
cd /home/me/myapp;mkvirtualenv myapp-env;workon myapp-env |
How can I convert this to a script? Alternatively, I'd be happy to convert the above one-liner to a variable, and execute that (I'm quite new to bash so I'm not even sure how to do that! But I could work it out relatively easily, I think).
Thanks for your help!