I\'m trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.
<Try following configuration (change to your path), which works for me:
[extensions]
; hg-git extention
hgext.bookmarks =
hggit = C:\Python26\Lib\site-packages\hg_git-0.2.1-py2.6.egg\hggit
In my case when I have empty value for hggit =
, I get the same error as you do in this case. But I can import dulwich
without problem in python shell, so you should check your easy-install.pth
(as pointed out by David) if it contains dulwich-0.5.0-py2.5.egg
.
I did install pure version of dulwich
as well.
That makes me think dulwich is not installed correctly, or not in the path.
You're absolutely right. Mercurial binary distributions for Windows are 'frozen' - they use the Python code and interpreter bundled with them and therefore independent of packages installed in system PYTHONPATH. When you specify path to hggit extension in Mercurial.ini, hg tries to import it using direct path, but dulwich library is not imported explicitly by hg and doesn't bundled with its library, so the import fails.
It is possible to add both Dulwich and HgGit into library.zip that is installed along with hg.exe, but for me the best way is to install everything from source including Mercurial and execute commands using .bat files installed into \Python\Scripts. In this case you will need to:
Install Dulwich - I'd use latest trunk snapshot for both Git and Dulwich.
python setup.py --pure install
Install latest HgGit snapshot
python setup.py install
Edit Mercurial.ini to enable hggit =
Had this problem today when installing the latest TortoiseHg.
Get the latest python 2.7 (I used 2.7.16) setup on your system, you probably have this already. Get a command window and go to the c:\Python27 folder To run pip use Scripts\pip or easy_install use Scripts\easy_install Try pip -V to make sure you get the 2.7 version and not some 3.X version
Wrong:
c:\Python27>pip -V
pip 20.2.4 from c:\python38\lib\site-packages\pip (python 3.8)
Right:
c:\Python27>Scripts\pip -V
pip 20.2.4 from c:\python27\lib\site-packages\pip (python 2.7)
If dulwich or hg-git are installed already
Scripts\pip uninstall dulwich
Scripts\pip uninstall hg-git
Install hg-git
Scripts\easy_install install hg-git
You should now have two folders
C:\Python27\Lib\site-packages\dulwich-0.19.16-py2.7-win-amd64.egg\dulwich
C:\Python27\Lib\site-packages\hg_git-0.9.0-py2.7.egg\hggit
It will only work if Dulwich is version 0.19.16 (less than 0.20.x)
Copy these folders (dulwich and hggit) into the zip-file C:\Program Files\TortoiseHg\lib\library.zip
folder in zip file
Until you get import dulwich
to work, hggit
won't work. Check that the dulwich
egg file is in your easy-install.pth
file under site-packages
.
For further debugging you can try ask pkg_resources
about it:
import pkg_resources
pkg_resources.require("dulwich")