I don't have administrator privileges (root), but I install the python package in my local environment.
Confirmed in the following raw environment.
$ docker run --rm -i -t docker.io/centos:7.3.1611 /bin/bash
//It has python, but no pip command.
$ python -V
Python 2.7.5
$ pip
-bash: pip: command not found
//First, prepare the pip command
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py --user
//When you execute the above command,.Install + path is added to local
$ ll ~/.local/bin/pip
-rwxrwxr-x 1 ymko ymko 201 Jul 15 03:58 /home/ymko/.local/bin/pip
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ymko/.local/bin:/home/ymko/bin
//It disappears when you log off, so add it
$ echo "export PATH=$HOME/.local/bin:\$PATH" >> ~/.bashrc
//Error that cannot be written in the system area when trying to install as it is
$ pip install bottle
IOError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/bottle.pyc'
// --Install locally as user
$ pip install bottle --user
Collecting bottle
Installing collected packages: bottle
Successfully installed bottle-0.12.13
//Also in the module search path.Contains local stuff
$ python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/home/ymko/.local/lib/python2.7/site-packages', '/usr/lib64/python2.7/site-packages', '/usr/lib/python2.7/site-packages']
pip_user_install.sh
#!/bin/bash
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
grep .local/bin ~/.bashrc
if [ $? != 0 ]; then
echo "export PATH=$HOME/.local/bin:\$PATH" >> ~/.bashrc
fi
Install python package in offline environment -Qiita
Recommended Posts