HG-Git:AttributeError:' bytes'对象没有属性' encode' [英] HG-Git: AttributeError: 'bytes' object has no attribute 'encode'

查看:68
本文介绍了HG-Git:AttributeError:' bytes'对象没有属性' encode'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to clone a git repository with mercurial and hg-git, but an AttributeError keeps coming up. When I run hg clone git://github.com/michaelfm1211/simpleserve, the output I get is this:

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 install hg 安装了Mercurial,并用 ~/brew/opt/python@3.8/bin/easy_install-3.8 hg-git 安装了hg-git,因为已将Homebrew配置为安装到〜/brew而不是/usr/local.

I have no idea why this is happening. I've installed Mercurial with brew install hg and hg-git with ~/brew/opt/python@3.8/bin/easy_install-3.8 hg-git, because I've configured Homebrew to install to ~/brew instead of /usr/local.

推荐答案

AttributeError: 'bytes' object has no attribute 'encode'

首先检查您用于Mercurial的python版本.

Check first your python version used for Mercurial.

~/brew/opt/python@3.8 可能意味着Python 3.

~/brew/opt/python@3.8 means probably Python 3.

但是: hg-git 线程提到:

However: This hg-git thread mentions:

hg-git 尚未在Python3上运行,但支持即将推出.

hg-git does not work yet on Python3, but support may be coming soon.

hg-git 在Python 3和我怀疑您实际上是在Python 2上运行Mercurial.

hg-git can’t run that far on Python 3 and I suspect that you’re actually running Mercurial on Python 2.

请参见 hg-git 问题298 .

See hg-git issue 298.

这篇关于HG-Git:AttributeError:&amp;#39; bytes&amp;#39;对象没有属性&amp;#39; encode&amp;#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆