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 6960463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:24:19+00:00 2026-05-27T15:24:19+00:00

I have the DVCS Mercurial on my PATH in a Windows system respective in

  • 0

I have the DVCS Mercurial on my PATH in a Windows system respective in a GNU/Linux system. If I open a Bash shell in GNU/Linux I can execute hg (the Mercurial command), the same goes if I open a Command Prompt in Windows.

I would like to execute hg and check exit status and capture the output. I know about the subprocess module and check_output. But I can´t get it to use my PATH. I would prefer not to hard code the path as I want the script to work as long as you have Mercurial on your path.

An example would be greatly appreciated.

Happy holidays!

  • 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-27T15:24:20+00:00Added an answer on May 27, 2026 at 3:24 pm

    If you already have hg in your path you shouldn’t need anything special in the call to subprocess since you should get the same environment.

    Anyway, if you want to explicitly add a PATH environment variable to your subprocess, you can do this:

    env = os.environ.copy()
    env['PATH'] = <whatever you need here>
    subprocess.Popen(<hg command>, env=env)
    

    This code copies the environment you’re getting from your shell and overwrites the PATH variable. You might want to append to PATH instead if you’re going to use the same env dictionary to run other commands.

    There’s no need to copy the whole environment, but this will prevent other problems you might have from happening because other environment variables are missing.

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

Sidebar

Related Questions

I have a workflow question related to Mercurial (possibly applicable to other DVCS). The
I work for a web development company that uses Mercurial as its DVCS of
I'm fairly new to Perforce but I already have experience with DVCS like Git
Have an app that can use tts to read text messages. It can also
I have been hearing a lot of good things about DVCS systems, in particular
I have a system that's broken down to three different programming languages: C#, C++
I have a bit of a dvcs design question: I have a project that
I'm going through Bitbucket and I can't seem to find any Mercurial repositories that
I have the following situation: I have site A, which has it's Mercurial repo,
have written this little class, which generates a UUID every time an object of

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.