marker
marker copied to clipboard
TypeError: cannot use a string pattern on a bytes-like object
When trying to run install.py, i get this error:
Traceback (most recent call last):
File "./install.py", line 109, in <module>
main()
File "./install.py", line 81, in main
verify_requirements()
File "./install.py", line 61, in verify_requirements
m = re.search('(\d).(\d)', version_text)
File "/usr/lib/python3.5/re.py", line 173, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object
On my system, when using pipes, i do sometimes get this weird error message (line 2 below). I haven't been able to figure out the cause, but i haven't seen any side effects from it before now, so i don't know if it is the problem here:
$ bash --version | head -1
bash: child setpgid (20301 to 20297): Operation not permitted
GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)
Here's what i get in the REPL:
$ python
Python 3.5.0 (default, Sep 20 2015, 11:28:25)
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.Popen("bash --version | head -1", shell=True, stdout=subprocess.PIPE).stdout.read()
b'GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)\n'
It works if i change line 60 to set version_text manually:
version_text = "GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)"
hmm, yes. the first line in bash --version is expected to be the version string. But in your case there is an error(or warning, I'm not sure):
bash: child setpgid (20301 to 20297): Operation not permitted
but that error message goes to stderr, not stdout:
$ bash --version | head -1 >/dev/null
bash: child setpgid (9003 to 8999): Operation not permitted
$ (bash --version | head -1) 2>/dev/null
GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)
so install.py shouldn't be reading in that line, right?
I got the same issue. It happens because you use a string pattern on a bytes object. Replace line 61 with following line will fix this issue:
m = re.search(b'(\d).(\d)', version_text)
I fixed this error by using Python 2.
I just got this issue too