Mercurial error *** failed to import extension hggit: No module named hggit
Asked Answered
M

7

39

I installed Mercurial on my Mac, and it's wonderful. For me it's easier to grasp than Git so I wanted to use it to manage git-repositories. Therefore I installed hg-git with the following instructions:

http://hg-git.github.com/

However, each time I issue a hg command it returns this error message:

  Mercurial error *** failed to import extension hggit: No module named hggit 

It might be important to note that I'm on a Mac not Gnu/Linux or MS-Windows.

Does any one know how to resolve this?

Maronite answered 27/2, 2011 at 14:6 Comment(1)
Funny, this issue is still happening with me now in 2021... And their documentation is even incorrect. It's pip3 install hg-git (and not hggit)Scarborough
F
21

After installing hg-git with the following command:

easy_install hg-git

Does the following work?

python -c "import hggit"

What does this say for you:

head -n1 `which hg`

The point of the latter command is to verify that the Python hg runs under has hggit installed. In my case it says '#!/usr/bin/python', which is my standard python command.

What does this say:

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.a­pp/Contents/MacOS/Python -c "import hggit"
Fireeater answered 27/2, 2011 at 14:37 Comment(10)
Well if I run that command it doesn't return anything, so no error message.Maronite
@Stofke: is the same Python used to run hg? I'd think that hg can't find your hggit installation.Fireeater
@Stofke: Case in point, I just installed hggit under Python 2.7, while the hg in my path is installed for Python 2.6. I get the exact same error as you :)Fireeater
head -n1 which hg returns this #!/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/PythonMaronite
python --version returns 2.6.1Maronite
See the last test I added (concerning /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.a­pp/Contents/MacOS/Python), please.Fireeater
Thanks I have got it working, I happened to have two version of python installed in different locations, so yes that was the problem. I removed one and it works great now.Maronite
For me it was the opposite way :) easy_install 2.6; Python 2.7Derivation
In my case I installed Python via homebrew (OS X). Homebrew links easy_install to /usr/local/bin/easy_install. Calling /usr/bin/easy_install hg-git forced to use the system provided easy_install, which makes packages available to the system's Python install.Seniority
For this to really be an answer, it needs to incorporate what's in the comments into the actual answer...Cycle
L
46

Note for ubuntu users who install the "mercurial-git" package to get the hggit module on 12.04 some bright spark randomly renamed the module to just "git" so you need to change your ~/.hgrc to look something like

[extensions]
hgext.bookmarks =
git =
Lanceted answered 5/10, 2012 at 1:31 Comment(3)
Yeah, I'm not a fan of the name "git." Luckily, I just found out you can prefix it ("hgext.") just like the bookmarks extension!Windsucking
Yes, I have to do this change (follow by the document arr.gr/blog/2011/10/bitbucket-converting-hg-repositories-to-git), but this Hg-Git mercurial plugin doesn't convert any other branches, except master branch. So it is useless.Heliotype
@Heliotype Perhaps it didn't when you tried it in 2017 but it's working fine for my branches in 2019.Francoise
F
21

After installing hg-git with the following command:

easy_install hg-git

Does the following work?

python -c "import hggit"

What does this say for you:

head -n1 `which hg`

The point of the latter command is to verify that the Python hg runs under has hggit installed. In my case it says '#!/usr/bin/python', which is my standard python command.

What does this say:

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.a­pp/Contents/MacOS/Python -c "import hggit"
Fireeater answered 27/2, 2011 at 14:37 Comment(10)
Well if I run that command it doesn't return anything, so no error message.Maronite
@Stofke: is the same Python used to run hg? I'd think that hg can't find your hggit installation.Fireeater
@Stofke: Case in point, I just installed hggit under Python 2.7, while the hg in my path is installed for Python 2.6. I get the exact same error as you :)Fireeater
head -n1 which hg returns this #!/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/PythonMaronite
python --version returns 2.6.1Maronite
See the last test I added (concerning /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.a­pp/Contents/MacOS/Python), please.Fireeater
Thanks I have got it working, I happened to have two version of python installed in different locations, so yes that was the problem. I removed one and it works great now.Maronite
For me it was the opposite way :) easy_install 2.6; Python 2.7Derivation
In my case I installed Python via homebrew (OS X). Homebrew links easy_install to /usr/local/bin/easy_install. Calling /usr/bin/easy_install hg-git forced to use the system provided easy_install, which makes packages available to the system's Python install.Seniority
For this to really be an answer, it needs to incorporate what's in the comments into the actual answer...Cycle
I
5

I installed Python and TortoiseHg by:

brew cask install python
brew cask install tortoisehg

After following installation

sudo easy_install hg-git

I experienced similar problems (TortoiseHg: failed to import extension hggit: No module named hggit and so on...) and finally found a solution for my TortoiseHg on mac (first uninstall last hg-git by sudo pip uninstall hg-git):

sudo pip install mercurial
sudo pip install hg-git

After installation with pip and adding bookmarks to all important branches, e. g. ...

hg bookmark -r default master
hg bookmark -r branchename bookmarkname

... I could push HG repository to Git:

hg push git+ssh://[email protected]/reponame.git --traceback

Note: use ssh! - causes fewer problems with large repositories

Note 2: --traceback tells you about problems

Inflame answered 13/5, 2015 at 14:20 Comment(1)
Uninstall, reinstall mercurial and hg-git worked best for me on mac. This is the simplest answer: sudo pip uninstall hg-git && sudo pip install mercurial && sudo pip install hg-git. Done.Cycle
E
5

I got this error as well even after downloading the latest Tortoisehg and making sure the hggit plugin was installed as well as my .ini & hgrc files had the right entry to enable hggit.

Turns out my problem was that I had both mercurial and tortoisehg in my path. So when I ran any hg commands, it was using the hg.exe in mercurial folder as opposed to the hg.exe in the torsoisehg directory.

This makes sense but my mercurial installation did not have the plug ins. My fix was to remove mercurial from my path so hg commands go through the tortoisehg directory since it has hg completely bundled. Note however, the recommended option might be to upgrade mercurual to a version that has the plugins that one needs but this is what worked for me. I tried replacing the library.zip in mercurial with the one in tortoisehg and this worked but it led to other errors as one would imagine.

Effeminate answered 1/2, 2016 at 20:17 Comment(0)
E
2

I had the same problem as I saw via brew install mercurial some packages are missing.

Do a test if any package missed like: python -c "import hggit"

My fix: Uninstall all packages:

brew uninstall mercurial

install with pip like:

  • sudo easy_install pip ( if you don't have pip )

  • sudo pip install mercurial and

  • sudo pip install hg-git

then

hg bookmark -r default master

Elatia answered 5/2, 2020 at 12:35 Comment(0)
B
1

I had the same problem, and found that installing hg-git and dulwich via easy_install worked if I used the --user option. This installed the package into ~/Library/Python/2.7/lib/python/site-packages.

To see where this option will install a package on your machine, run easy_install --help. By the documentation for the --user option, it shows the install directory that will be used.

Blucher answered 26/5, 2015 at 9:3 Comment(0)
D
0
  1. clone hggit from http://bitbucket.org/durin42/hg-git
  2. get hg-git path from your local computer. in my local computer /Users/coco/go/src/bitbucket.org/durin42/hg-git/hggit
  3. add path to ~.hgrc file using your text editor
  4. add the following lines of code

    [extenstions]
    hggit = /Users/coco/go/src/bitbucket.org/durin42/hg-git/hggit
    
  5. try to hg clone/push/pull form github

Dominion answered 2/3, 2019 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.