HG Git:AttributeError:“bytes”对象没有属性“encode”

HG Git:AttributeError:“bytes”对象没有属性“encode”,git,version-control,mercurial,homebrew,hg-git,Git,Version Control,Mercurial,Homebrew,Hg Git,我正试图用mercurial和hg git克隆git存储库,但AttributeError不断出现。当我运行hg克隆时git://github.com/michaelfm1211/simpleserve,我得到的输出是: destination directory: simpleserve ** unknown exception encountered, please report by visiting ** https://mercurial-scm.org/wiki/BugTracker

我正试图用mercurial和hg git克隆git存储库,但AttributeError不断出现。当我运行hg克隆时git://github.com/michaelfm1211/simpleserve,我得到的输出是:

destination directory: simpleserve
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 3.8.3 (default, May 31 2020, 07:24:01) [Clang 11.0.3 (clang-1103.0.32.62)]
** Mercurial Distributed SCM (version 5.4.1)
** Extensions loaded: hggit
Traceback (most recent call last):
  File "/Users/michaelfm1211/brew/bin/hg", line 43, in <module>
    dispatch.run()
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 112, in run
    status = dispatch(req)
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 298, in dispatch
    ret = _runcatch(req) or 0
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 472, in _runcatch
    return _callcatch(ui, _runcatchfunc)
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 481, in _callcatch
    return scmutil.callcatch(ui, func)
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/scmutil.py", line 152, in callcatch
    return func()
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 462, in _runcatchfunc
    return _dispatch(req)
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 1225, in _dispatch
    return runcommand(
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 910, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 1237, in _runcommand
    return cmdfunc()
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/dispatch.py", line 1223, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/util.py", line 1864, in check
    return func(*args, **kwargs)
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/commands.py", line 1903, in clone
    r = hg.clone(
  File "/Users/michaelfm1211/brew/Cellar/mercurial/5.4.1/lib/python3.8/site-packages/mercurial/hg.py", line 900, in clone
    exchange.pull(
  File "/Users/michaelfm1211/brew/lib/python3.8/site-packages/hg_git-0.9.0a1-py3.8.egg/hggit/util.py", line 64, in inner
    return f(*args, **kwargs)
  File "/Users/michaelfm1211/brew/lib/python3.8/site-packages/hg_git-0.9.0a1-py3.8.egg/hggit/__init__.py", line 366, in exchangepull
    pullop.cgresult = repo.githandler.fetch(remote.path, heads)
  File "/Users/michaelfm1211/brew/lib/python3.8/site-packages/hg_git-0.9.0a1-py3.8.egg/hggit/git_handler.py", line 283, in fetch
    result = self.fetch_pack(remote, heads)
  File "/Users/michaelfm1211/brew/lib/python3.8/site-packages/hg_git-0.9.0a1-py3.8.egg/hggit/git_handler.py", line 1223, in fetch_pack
    ret = localclient.fetch_pack(path, determine_wants, graphwalker,
  File "/Users/michaelfm1211/brew/lib/python3.8/site-packages/dulwich/client.py", line 876, in fetch_pack
    proto, can_read, stderr = self._connect(b'upload-pack', path)
  File "/Users/michaelfm1211/brew/lib/python3.8/site-packages/dulwich/client.py", line 1015, in _connect
    b'git-' + cmd, path, b'host=' + self._host.encode('ascii'))
AttributeError: 'bytes' object has no attribute 'encode'
我不知道为什么会这样。我已经用brew安装了Mercurial,用~/brew/opt安装了hg和hg git/python@3.8/bin/easy_install-3.8 hg git,因为我已将Homebrew配置为安装到~/brew而不是/usr/local

首先检查用于Mercurial的python版本

~/brew/opt/python@3.8可能是指Python 3

但是:提到:

HgGit还不能在Python3上工作,但支持可能很快就会到来

HgGit在Python3和 我怀疑您实际上正在Python 2上运行Mercurial

首先检查用于Mercurial的python版本

~/brew/opt/python@3.8可能是指Python 3

但是:提到:

HgGit还不能在Python3上工作,但支持可能很快就会到来

HgGit在Python3和 我怀疑您实际上正在Python 2上运行Mercurial


请参阅。

这起作用了!我用pip和Python 2重新安装了Mercurial。唯一的错误是pip安装了dulwich 0.20,它不支持Python2See:,但我所要做的就是pip安装dulwich==0.19.6。这很有效!我用pip和Python 2重新安装了Mercurial。唯一的错误是pip安装了dulwich 0.20,它不支持Python2See:,但我所要做的就是pip安装dulwich==0.19.6。
AttributeError: 'bytes' object has no attribute 'encode'