These instructions describe how to install Python from Anaconda on a Linux server.
Note that these steps refer to Miniconda, which is a minimal installation of Python, conda, and a small number of other packages. After you install a base version of Python with Miniconda, you can optionally install additional packages into the Python environment.
Install required dependencies#
Use the following commands to install the dependencies required to install Python for your Linux distribution.
$ sudo yum install bzip2
$ sudo apt-get install bzip2
$ sudo zypper install bzip2
Download and install Python#
Download and install Python 3.7.7 by running the following commands:
$ curl -O https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Linux-x86_64.sh $ sudo bash Miniconda3-py37_4.8.3-Linux-x86_64.sh -bp /opt/python/3.7.7/
The above command will install Python 3.7.7, which is the default version of Python available in the version of that installer. You can download and install a different version of Python by using another version of the Miniconda installer, or by creating a new Python environment with a different version of Python.
Verify Python installation#
Verify that Python is installed by running the following command:
$ /opt/python/3.7.7/bin/python --version
(Optional) Install additional Python packages#
You can install additional Python packages into the your Python environment by running a command such as:
$ sudo /opt/python/3.7.7/bin/pip install altair beautifulsoup4 cloudpickle \ cython dask gensim keras matplotlib nltk numpy pandas pillow pyarrow \ requests scipy scikit-image scikit-learn scrapy seaborn spacy sqlalchemy \ statsmodels tensorflow xgboost
(Optional) Add Python to the system PATH#
You can configure Python on the system
PATH so that users can use
within a terminal to install packages to their home directory, similar to
how R works with
The recommended method to add Python to the
PATH is to append the version of
Python that you installed to the system-wide
PATH variable. For example, this
can be defined in a script within the
(Optional) Install multiple versions of Python#
If you want to install multiple versions of Python on the same server, you can repeat these steps to specify, download, and install a different version of Python alongside existing versions to other locations.
For example, you can run the following commands to install Python 2.7.16:
$ curl -O https://repo.anaconda.com/miniconda/Miniconda2-4.7.12-Linux-x86_64.sh $ sudo bash Miniconda2-4.7.12-Linux-x86_64.sh -bp /opt/python/2.7.16/
Or, you can run the following commands to install Python 3.6.5:
$ curl -O https://repo.anaconda.com/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh $ sudo bash Miniconda3-4.5.4-Linux-x86_64.sh -bp /opt/python/3.6.5/