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

独自空忆成欢 提交于 2019-12-03 04:25:32

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"

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 =

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://git@gitlab.URL/reponame.git --traceback

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

Note 2: --traceback tells you about problems

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.

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.

Klikkanan
  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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!