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>
main(sys.argv[1:])
File "/home/username/bin/repo", line 705, in main
_Init(args)
File "/home/username/bin/repo", line 234, in _Init
_CheckGitVersion()
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:
Writing objects: 100% (12/12), 966 bytes, done.
Total 12 (delta 11), reused 0 (delta 0)
o ssh://[email protected]:29418/stelvio/mm
![remote rejected] branchname -> refs/for/main_dev (you are not committer [email protected])
error: failed to push some refs to 'ssh://[email protected]:29418/project/one'
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']
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
...
ver_str = proc.stdout.read().strip()
proc.stdout.close()
proc.wait()
if not ver_str.startswith('git version '):
read
ing 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).
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
to
#!/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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With