Install python on xserver to use pip

Purpose

Since the Xserver does not have administrator privileges

Is included, but there is no package management pip & cannot be installed

What i did

Install Linuxbrew and put python with brew

Install Linuxbrew

In a suitable directory

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

After , replace XXXXX with your own account on Xserver

...
==> Select the Homebrew installation directory
- Enter your password to install to /home/linuxbrew/.linuxbrew (recommended)
- Press Control-D to install to /home/XXXXX/.linuxbrew
- Press Control-C to cancel installation
[sudo]XXXXX password:

Is asked, so use Control-D to install it in the directory under your account.

Download and install for a while ...

When the installation is completed, you will be advised as Next steps as follows, so execute it as it is

==> Next steps:
- Run `brew help` to get started
- Further documentation: 
    https://docs.brew.sh
- Install the Homebrew dependencies if you have sudo access:
    sudo yum groupinstall 'Development Tools'
    See https://docs.brew.sh/linux for more information
- Add Homebrew to your PATH in /home/XXXXX/.bash_profile:
    echo 'eval $(/home/XXXXX/.linuxbrew/bin/brew shellenv)' >> /home/XXXXX/.bash_profile
    eval $(/home/XXXXX/.linuxbrew/bin/brew shellenv)
- We recommend that you install GCC:
    brew install gcc

Execute the following command. gcc is included when you install linuxbrew, but it recommends it, so just in case.

echo 'eval $(/home/XXXXX/.linuxbrew/bin/brew shellenv)' >> /home/XXXXX/.bash_profile
eval $(/home/XXXXX/.linuxbrew/bin/brew shellenv)
brew install gcc

Insert Python3 series (minor version was not specified this time)

brew install python3

After installing, 3.8.5 is included.

$ python3 --version
Python 3.8.5

$ pip3 --version
pip 20.1.1 from /home/XXXXX/.linuxbrew/opt/[email protected]/lib/python3.8/site-packages/pip (python 3.8)

↑ In python --version, 2.7.x series is displayed because it is passed through the path of / usr / bin / python.

important point

If you check .bash_profile

PATH=$PATH:$HOME/bin

export PATHeval $(/home/XXXXX/.linuxbrew/bin/brew shellenv)

And there are no line breaks in PATH and eval, and the PATH will not work the next time you log in. I'll fix it ↓

PATH=$PATH:$HOME/bin

export PATH
eval $(/home/XXXXX/.linuxbrew/bin/brew shellenv)

Recommended Posts