TypeError when trying to “repo init” on Python 3.3

I have Arch Linux
Python 3.3.0
I’ve downloaded the latest repo, and if i try to do the repo init from the Google example, i get this error:

 [username@otp-username-l2 teste]$ repo init -u https://android.googlesource.com/platform/manifest
 Traceback (most recent call last):
 File "/home/username/bin/repo", line 738, in <module>
File "/home/username/bin/repo", line 705, in main
 File "/home/username/bin/repo", line 234, in _Init
 File "/home/username/bin/repo", line 274, in _CheckGitVersion
if not ver_str.startswith('git version '):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

The reason for which i am forced to do a new repo init is that i must do a commit from an already initialized repo, but i’ve changed the git user from everywhere, and i still get this:

  • Confused by 'up-to-date' message in git workflow
  • Rename a git submodule
  • Fixing up a commit that happened before a merge
  • List of changed files
  • Can _netrc handle passphrases with spaces?
  • Git push to one remote repo which deploys to multiple other remote repositories
  • Writing objects: 100% (12/12), 966 bytes, done.
    Total 12 (delta 11), reused 0 (delta 0)
    o ssh://new.username@
    ![remote rejected] branchname -> refs/for/main_dev (you are not committer  oldusername@email.com)
     error: failed to push some refs to 'ssh://new.username@'

  • How can QA test multiple features at once with feature branching in Gitflow workflow?
  • I got error while using “git push heroku master”
  • How does git handle moving files in the file system?
  • git diff unique to merge commit
  • How can I remove everything from a remote Git repository?
  • commit one at a time in git
  • 3 Solutions collect form web for “TypeError when trying to “repo init” on Python 3.3”

    Repo does not yet fully support Python 3. Some work has been done, such as using the print function and importing the correct urllib, but that work doesn’t appear to have been finished.

    For now, you’ll need to use it with Python 2. You could edit the shebang at the top of the repo executable by replacing python with python2 or you could run:

    python2 `which repo`

    assuming you have a version of Python 2 installed in your path as python2.

    You can easily reproduce the problem:

    Python 3.2.3 (default, Nov  7 2012, 19:36:04) 
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> b'asd'.startswith('asd')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: startswith first arg must be bytes or a tuple of bytes, not str

    And here is the relevent code of _CheckGitVersion():

    def _CheckGitVersion():
      cmd = [GIT, '--version']
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
      ver_str = proc.stdout.read().strip()
      if not ver_str.startswith('git version '):

    reading the stdout of the Popen call returns bytes, and so what is passed to startswith has to also be bytes (raw bytes of data) rather than str (a sequence of Unicode code points).

    I ran into the same problem, agf’s solutions made the repo-script work, but it still exited stating that it won’t work with python 3:

    error: Python 3 support is not fully implemented in repo yet.
    Please use Python 2.6 – 2.7 instead.

    The (admittedly rather dirty) way around this for me was to change the symlink for the python bin from python3 to python2.

    Remember to revert this once you’re done!

    Just stumbled upon this error while trying to revive my P990.

    The first fix is to modify the repo command (in ~/bin in your case, otherwise check which repo to find where it is) and change the first line from

    #!/usr/bin/env python


    #!/usr/bin/env python2

    This allows you to repo init, but you will run into the message klauspeter mentioned:

    error: Python 3 support is not fully implemented in repo yet.
    Please use Python 2.6 - 2.7 instead.

    I wouldn’t recommend changing the system-wide symlink. Instead, navigate into the newly created .repo folder.

    If you started repo init in $basedir, you want to check $basedir/.repo/repo. Inside you’ll find a local repo installation, again having a shebang with plain ‘python’ (we want python2).

    So edit all files containing that line (main.py, repo and wrapper.py) according to the first steps above and you’re good to go. For me repo now even asked me to update my global installation (that is, copying $basedir/.repo/repo/repo to ~/bin), which you’re free to do (that version is ‘fixed’ now).

    Git Baby is a git and github fan, let's start git clone.