From 5dbc40a04874c65db51386ef2fce90592e735abf Mon Sep 17 00:00:00 2001 From: MRXLT Date: Fri, 8 May 2020 08:16:56 +0000 Subject: [PATCH] bug fix for py3 && fix setup.py --- python/examples/lac/lac_reader.py | 6 ++++-- python/paddle_serving_app/reader/lac_reader.py | 7 ++++--- python/setup.py.client.in | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/python/examples/lac/lac_reader.py b/python/examples/lac/lac_reader.py index c9f31c14..488e7ced 100644 --- a/python/examples/lac/lac_reader.py +++ b/python/examples/lac/lac_reader.py @@ -14,8 +14,10 @@ from paddle_serving_client import Client import sys -reload(sys) -sys.setdefaultencoding('utf-8') +py_version = sys.version_info[0] +if py_version == 2: + reload(sys) + sys.setdefaultencoding('utf-8') import os import io diff --git a/python/paddle_serving_app/reader/lac_reader.py b/python/paddle_serving_app/reader/lac_reader.py index a0ed0bbe..720bbf9c 100644 --- a/python/paddle_serving_app/reader/lac_reader.py +++ b/python/paddle_serving_app/reader/lac_reader.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from paddle_serving_client import Client import sys -reload(sys) -sys.setdefaultencoding('utf-8') +py_version = sys.version_info[0] +if py_version == 2: + reload(sys) + sys.setdefaultencoding('utf-8') import os import io diff --git a/python/setup.py.client.in b/python/setup.py.client.in index 58061f7c..18d47253 100644 --- a/python/setup.py.client.in +++ b/python/setup.py.client.in @@ -42,9 +42,9 @@ def copy_lib(): lib_list = ['libpython2.7.so.1.0', 'libssl.so.10', 'libcrypto.so.10'] if py_version == 2 else ['libpython3.6m.so.1.0', 'libssl.so.10', 'libcrypto.so.10'] os.popen('mkdir -p paddle_serving_client/lib') for lib in lib_list: - r = os.popen('whereis {}'.format(lib)) + r = os.popen('locate {}'.format(lib)) text = r.read() - os.popen('cp {} ./paddle_serving_client/lib'.format(text.strip().split(' ')[1])) + os.popen('cp {} ./paddle_serving_client/lib'.format(text.strip())) max_version, mid_version, min_version = python_version() -- GitLab