'SageMaker Studio Image - pip not found and no python 3 in terminal for Python 3 notebook instance
Launched Data Science Python 3 instance in the SageMaker Studio.
Launched a terminal from the Notebook menu "Launch terminal in current SageMaker image".
Tried to run pip but it says not found. Do I need to install pip by myself?
root@datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:~/# pip
bash: pip: command not found
Alto there is no Python3 available apparently from within the terminal.
root@datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:~# python3
bash: python3: command not found
root@datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:~# python --version
Python 2.7.16
root@datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:/usr/bin# ls -lrt | grep python
lrwxrwxrwx 1 root root 29 Mar 4 2019 pyversions -> ../share/python/pyversions.py
lrwxrwxrwx 1 root root 9 Mar 4 2019 python2 -> python2.7
lrwxrwxrwx 1 root root 7 Mar 4 2019 python -> python2
-rwxr-xr-x 1 root root 1056 Mar 4 2019 dh_python2
-rwxr-xr-x 1 root root 3689352 Oct 10 2019 python2.7
lrwxrwxrwx 1 root root 23 Oct 10 2019 pdb2.7 -> ../lib/python2.7/pdb.py
However, the notebook says it is Python3.
from platform import python_version
print(python_version())
---
3.7.10
And can run pip in the cell.
Appreciate any explanation what is going on.
Solution 1:[1]
SageMaker Studio image terminals use conda for package management. The data science notebook uses the base environment. You can use pip once you switch to base (also note that the python version is 3.7).
root@datascience-1-0-ml-t3-medium-xx:~# conda env list
# conda environments:
#
base * /opt/conda
root@datascience-1-0-ml-t3-medium-xx:~# conda activate base
(base) root@datascience-1-0-ml-t3-medium-xx:~# pip show pip
Name: pip
Version: 21.3.1
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: [email protected]
License: MIT
Location: /opt/conda/lib/python3.7/site-packages
Requires:
Required-by:
(base) root@datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:~# python --version
Python 3.7.10
I work at AWS and my opinions are my own.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |



