From bb65988a814ead99c55e057173f5a7cf83bf99bb Mon Sep 17 00:00:00 2001 From: CJ Yang Date: Fri, 3 May 2019 17:30:51 -0400 Subject: [PATCH 1/2] fix the error "pip has not attribute 'main'" for pip version 10 and onward. --- bindings/python/cntk/sample_installer.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bindings/python/cntk/sample_installer.py b/bindings/python/cntk/sample_installer.py index 9402a7421e32..e529454e6c0f 100644 --- a/bindings/python/cntk/sample_installer.py +++ b/bindings/python/cntk/sample_installer.py @@ -15,9 +15,15 @@ import zipfile import string import pip + +if int(pip.__version__.split('.')[0])>9: + from pip._internal import main +else: + from pip import main + try: - from urllib.request import urlretrieve -except ImportError: + from urllib.request import urlretrieve +except ImportError: from urllib import urlretrieve from cntk import __version__ @@ -76,7 +82,7 @@ def show_message(text): requirements_file = os.path.join(directory, 'requirements.txt') if os.path.isfile(requirements_file): show_message('INFO: installing requirements') - pip.main(['install', '-r', requirements_file]) + main(['install', '-r', requirements_file]) else: show_message('WARNING: file %s does not exist, modules to run the samples may be missing' % (requirements_file)) @@ -95,7 +101,7 @@ def show_message(text): default=default_sample_dir()) parser.add_argument('-q', '--quiet', action='store_true', help='suppress output (default: %(default)s)', default=False) - + options = parser.parse_args(sys.argv[1:]) install_samples(options.url, options.directory, options.quiet) From d825b6268fdcb7728d3c1f3303bbbcbe59dc3165 Mon Sep 17 00:00:00 2001 From: CJ Yang Date: Fri, 3 May 2019 17:46:55 -0400 Subject: [PATCH 2/2] apply PEP-8 style guide. --- bindings/python/cntk/sample_installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/cntk/sample_installer.py b/bindings/python/cntk/sample_installer.py index e529454e6c0f..5dcce2502fc5 100644 --- a/bindings/python/cntk/sample_installer.py +++ b/bindings/python/cntk/sample_installer.py @@ -16,7 +16,7 @@ import string import pip -if int(pip.__version__.split('.')[0])>9: +if int(pip.__version__.split('.')[0]) > 9: from pip._internal import main else: from pip import main