Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the error "pip has not attribute 'main'" for pip version 10 and later #3658

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions bindings/python/cntk/sample_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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))
Expand All @@ -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)