How to check if the installed Mercurial (hg) is using Python2 or Python3?

1.2k views Asked by At

I wanted to install the hg-git extension with python pip but I'm not sure if I should use pip (Python2) or pip3 (Python3).

hg version gives this:

$ hg version
Mercurial Distributed SCM (version 4.8.2)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2018 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Enabled extensions:

  fetch     internal
  graphlog  internal
  histedit  internal
  strip     internal
  mq        internal
  purge     internal
  rebase    internal
  record    internal
$

I first tried pip3 install hg-git and it did not work after installation. Then I used pip and it worked. Just curious how to check the Mercuial's Python version in the first place.

2

There are 2 answers

0
Dan Villiom P. Christiansen On BEST ANSWER

Mercurial has a rather helpful command that allows you to inspect and verify the installation:

$ hg debuginstall
checking encoding (UTF-8)...
checking Python executable (/usr/local/bin/python3.7)
checking Python implementation (CPython)
checking Python version (3.7.9)
[…]
1
Christophe Muller On

I am running Ubuntu 20.04 and on my Mercurial version (5.3.1) it is still using Python2, so I guess it should be the same. You can check it with:

$ head -1 /usr/bin/hg 
#! /usr/bin/python2

If it were something like /usr/bin/python then you could also check what version it is:

$ python --version
Python 2.7.18