Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6612245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:04:28+00:00 2026-05-25T20:04:28+00:00

So, once again, I make a nice python program which makes my life ever

  • 0

So, once again, I make a nice python program which makes my life ever the more easier and saves a lot of time. Ofcourse, this involves a virtualenv, made with the mkvirtualenv function of virtualenvwrapper. The project has a requirements.txt file with a few required libraries (requests too :D) and the program won’t run without these libraries.

I am trying to add a bin/run-app executable shell script which would be in my path (symlink actually). Now, inside this script, I need to switch to the virtualenv before I can run this program. So I put this in

#!/bin/bash
# cd into the project directory
workon "$(cat .venv)"
python main.py

A file .venv contains the virtualenv name. But when I run this script, I get workon: command not found error.

Of course, I have the virtualenvwrapper.sh sourced in my bashrc but it doesn’t seem to be available in this shell script.

So, how can I access those virtualenvwrapper functions here? Or am I doing this the wrong way? How do you launch your python tools, each of which has its own virtualenv!?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:04:28+00:00Added an answer on May 25, 2026 at 8:04 pm

    Just source the virtualenvwrapper.sh script in your script to import the virtualenvwrapper’s functions. You should then be able to use the workon function in your script.

    And maybe better, you could create a shell script (you could name it venv-run.sh for example) to run any Python script into a given virtualenv, and place it in /usr/bin, /usr/local/bin, or any directory which is in your PATH.

    Such a script could look like this:

    #!/bin/sh
    # if virtualenvwrapper.sh is in your PATH (i.e. installed with pip)
    source `which virtualenvwrapper.sh`
    #source /path/to/virtualenvwrapper.sh # if it's not in your PATH
    workon $1
    python $2
    deactivate
    

    And could be used simply like venv-run.sh my_virtualenv /path/to/script.py

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Once again one of those: Is there an easier built-in way of doing things
Once again I have a problem which I can't find the solution to. A
I thought of re-framing this question once again, to make it clear. Thanks a
Once again a very beginner-ish question, but here I go: I would like to
Once again a question about the garbage collector in actionscript-3: If I have a
Once again I'm doing Java graphics (Graphics2D) but I noticed there is no Polygon.Double
Once again I find myself failing at some really simple task in C++. Sometimes
Once again I was in a design review, and encountered the claim that the
I need your expertise once again. I have a java class that searches a
I have once again fleshed out Ruby, after two years of not touching it,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.