Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Bench update python2.7 error after Centos7 update

I recently have a working development install of ERP Next on a Centos7 machine…
Bench version 5.0.0
ERP Next version 12.6.0
Frappe version 12.4.1
Recently updated Centos7 to 3.10.0-1127
(I did check and Python got updated to 2.7.5-88)
Now when I run a bench command i get the following:
$ bench start
Traceback (most recent call last):
File “/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/usr/lib/python2.7/site-packages/pkg_resources/init.py”, line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/lib/python2.7/site-packages/pkg_resources/init.py”, line 2793, in load_entry_point
return ep.load()
File “/usr/lib/python2.7/site-packages/pkg_resources/init.py”, line 2411, in load
return self.resolve()
File “/usr/lib/python2.7/site-packages/pkg_resources/init.py”, line 2417, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/home/erp/.bench/bench/cli.py”, line 3, in
from bench.utils import is_root, PatchError, drop_privileges, get_env_cmd, get_cmd_output, get_frappe, log, find_parent_bench
File “/home/erp/.bench/bench/utils.py”, line 23, in
import requests
File “/usr/lib/python2.7/site-packages/requests/init.py”, line 58, in
from . import utils
File “/usr/lib/python2.7/site-packages/requests/utils.py”, line 32, in
from .exceptions import InvalidURL
File “/usr/lib/python2.7/site-packages/requests/exceptions.py”, line 10, in
from urllib3.exceptions import HTTPError as BaseHTTPError
File “/usr/lib/python2.7/site-packages/urllib3/init.py”, line 10, in
from .connectionpool import (
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 31, in
from .connection import (
File “/usr/lib/python2.7/site-packages/urllib3/connection.py”, line 45, in
from .util.ssl_ import (
File “/usr/lib/python2.7/site-packages/urllib3/util/init.py”, line 5, in
from .request import make_headers
File “/usr/lib/python2.7/site-packages/urllib3/util/request.py”, line 5, in
from …exceptions import UnrewindableBodyError
ImportError: cannot import name UnrewindableBodyError

I have seen similar posts but cannot get my head around the steps to fix?
Any suggestions appreciated?

I’ve noticed bench 5 recently introduced moving python executables from 2.7 to 3.xx when running bench update. You should install python3 (don’t forget dependencies) and bench update.

Python 2.7 is eol.

Python3 is installed…sorry forgot to say that…
Package python3-3.6.8-13.el7.x86_64 already installed and latest version
Nothing to do

Is there a python3-urllib3 package that needs to be installed ( yum search urllib3)?

Has bench migrate-env python3.6 been run ?

Maybe bench setup requirements as well

python3-urllib3 package was not installed…I have now installed it.
Also mariadb.service is not starting after my centos7 update - will repost once this is working.

Database is fully functioning now…
Any BENCH command returns the error at the top of the thread…
This was fully functioning erp next installation before the centos7 update to 3.10.0-1127.
Any clues as to this behaviour??

open bench console
import sys
sys.version
import urllib3
import requests

any errors?

Same error string as the top of thread - this is true for any bench command.

The traceback shows you running in your Python 2.7 environment.

edit: This may fix that in CentOS too https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3

Instead of bench console , open a python interpreter and try those commands to see if the libraries are installed.

Did the following:
As a newbie let me know if I’m on the right track here?
[erp@localhost ~]$ alias python=’/usr/bin/python3’
[erp@localhost ~]$ python --version
Python 3.6.8
[erp@localhost ~]$ python3
Python 3.6.8 (default, Apr 2 2020, 13:34:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import sys
sys.version
‘3.6.8 (default, Apr 2 2020, 13:34:55) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]’

import urllib3
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘urllib3’

import requests
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘requests’

yum search urllib3
yum search requests

install the packages that provide the python3x libraries, you may need the python2x ones as well

We had the same issue and had to migrate the bench from Python 2.7 to 3.0 and then to 3.6. I believe an earlier post mentioned running “migrate-env python3”. This was how we were able to resolve the same issue.

I have installed urllib3 and requests.
I can run a python env and run all the commands suggested with out errors
[erp@localhost ~]$ alias python=’/usr/bin/python3’
[erp@localhost ~]$ python --version
Python 3.6.8
[erp@localhost ~]$ python3

import sys
sys.version
import urllib3
import requests

Still unsure where to go from here as “bench” still is broken and still gives the errors at the top of the post!

The CentOs machine is virtual or bare metal? Is there hosting involved?

If you google the ImportError: cannot import name UnrewindableBodyError message most of the results suggest a urllib3 problem. Many suggest reinstalling urllib3 and requests.

Maybe try what this one suggests.

Another suggests reinstalling awscli if that might be applicable.

Machine is my home computer.
Did the “this one” suggests…

May 1st edit:
These were the commands used;
sudo pip uninstall requests
sudo pip uninstall urllib3
sudo yum remove python-urllib3
sudo yum remove python-requests
(confirm that all those libraries have been removed)
sudo yum install python-urllib3
sudo yum install python-requests

As a side note I did notice this message:

You are using pip version 8.1.2, however version 20.1 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.

I did not do anything with awscli and it is not installed.

After uninstalling and re installing per the article…Tried, bench console - and it worked!! No bench commands have worked to this point…

Now I am nervous as to what to do next - bearing in mind that this was a working installation prior.
Should I try bench update?
Suggestions please? before I try further commands.

Try: bench migrate-env python3.6
and bench setup requirements
then bench update

All working perfectly now.
Thank you for the great resource of this Forum!!

1 Like

As another side note;
I have added this line to
/home/erp_user/.bashrc

User specific aliases and functions

alias python=’/usr/bin/python3’

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.