My Brain Cells

Easiest (and best) learning materials for anyone with a curiosity for machine learning and artificial intelligence, Deep learning, Programming, and other fun life hacks.

Install Python in Web Server


Check whether Python is already installed

Chances are Python is already installed on your hosted Linux server. If you’re unsure, follow these easy steps:

1. Run the following from your ssh terminal:

$ ls -la /usr/bin/python

Note: Keep in mind /usr/bin/python is the default location for the python executables.

2. Use the following command to see which version of Python you’re working with:

$ Python -V

Install Python 3

If you’re brave, you can install Python 3 yourself by taking the following steps:

1. Transfer the compression version of the files to your server.

$ wget

2. Decompress the files with the following command:

$ tar xvzf Python-3.4.3.tgz

Note: This will create the directory /home/user-name/Python-3.4.3 and automatically decompress all of Python’s files into their appropriate spots.

3. Go into that directory with:

$ cd Python-3.4.3

4. Once inside that directory, install your new version of Python.

$ ./configure --prefix=$HOME/.local

Note: This step sets up your configuration and makes files.

5. Then run this command:

$ make

6. And follow that up with:

$ make install

The last command will install two of the most useful Python utilities:

  • pip: Python’s recommended tool for installing Python packages.
  • setuptools: Enables you to download, build, install, and uninstall Python packages.

Fairly easy, but you’re not done yet. Next, you must add the path to your environment. I use vi, the one true editor, for this but you can use Emacs, nano, or any other pure text editor. Never use a word processor, such as Microsoft Word or LibreOffice Writer. These add formatting codes to their documents, which make them worse than useless for coding purposes.

1. Go into your Bash profile configuration file:

$cd $home
$ vi .bash_profile

2. With an editor, add the following lines, then save the file:

# Python 3 
export PATH="$HOME/.local/bin:$PATH"

3. Run the following to get your environment up to date:

$ source ~/.bash_profile

4. Then run the following from the shell and you should see Python 3.4.3:

$ python3 -V

You now have Python 3 installed. Congratulations!


Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top