Python for Scientists – Installation for Linux

If used properly, Anaconda can take most of the annoyances out of managing Python libraries and virtual environments. Even if corruption occurs (yes, it will happen), this series will equip you with means to replicate your working environments. Before we get to disaster recovery, we need a solid base installation. Remember, this post covers installation for Linux Operating Systems. Go here for a Windows 10 installation guide.

This post will cover

  • Download
  • Installation Prep
  • Installation
  • Post Installation

Click here for a list of related posts.

Updated: 2019-08-26

Download

Go here to see what versions are available for download. If you’re not sure if your Linux architecture is 32-bit or 64-bit type uname -a in a terminal window (NOTE: I suggest you refrain from using copy/paste. Type commands yourself to get used to it). If it returns x86_64 in the string, then its 64-bit. If not, it’s 32-bit. You can see below that my distribution is 64-bit. In Linux there are usually multiple ways to get the same result. If you are comfortable using a different command to find the architecture, then use that method.

You can either use wget to download the file, or save the file from the website above. I chose to use wget to download the file to my home directory. You can navigate to your home directory by typing cd and then press the Enter key. Type pwd (print working directory) to check your current directory. As you can see in the image below, I’m in /home/atmoguy. Your path will be /home/<username>.

Installation Prep

WARNING Your installation path CANNOT have special characters such as periods, commas, or parentheses. The path can only contain letters, numbers, back (or forward) slashes, and colons. Anaconda/Miniconda will not work with special characters in the installation path.

Navigate to your home directory if you have moved from the previous step, or to the location Miniconda3 was downloaded. I recommend installing Miniconda3 in your home directory, but you can install it pretty much anywhere. First we need to change the permissions of the downloaded file so it can be executed. That is done by typing chmod +x Miniconda3-latest-Linux-x86_64.sh and press the Enter key.

Installation

Now that the file is executable, type ./Miniconda3-latest-Linux-x86_64.sh followed by the Enter key. This will start the installer as seen in the picture above.

After you press Enter as the prompt suggests, you will see many lines of text that make up the license agreement. At the bottom left corner you will see the highlighted word MORE. To get through the license agreement, press the Enter key to advance to the next line. Eventually, it will ask if you agree. Type yes if you want to continue installing followed by Enter.

The next step is to chose where Miniconda3 will be installed. It can really be installed anywhere, but I suggest your home directory as in the image above. If you want to install in another directory, type the path and then press Enter. If you want to install Miniconda3 in the default directory provided, press Enter. This is the option within the red box above.

A lot of lines are going to fly by as Miniconda3 packages are downloaded and installed. The next step is to choose whether to initialize Miniconda3 or not. I chose to initialize it so it’s added to my path upon login. This allows me to type conda without needing to adjust any environment variables.

I recommend typing yes and then pressing the Enter key.

Important! After doing this, close the terminal window and open a new one so that the paths are updated.

Post Installation

After you have closed the current terminal and opened a new one, type conda into the command line and then press the Enter key. You should see something similar to the image below.

You should also see an indication that you’re using the root – or base – conda environment. The current conda environment will always be displayed in the location outlined in red below.

DO NOT start installing packages for a project in the root Miniconda environment (FYI the root environment is what we just installed). DO NOT (it’s worth repeating) install anything in the root Miniconda environment, because this can corrupt the entire python environment which results in re-installation of everything (huge time waste/panic city/experience gained the hard way). If you accidentally install something in root, remove it.

The next step is to create our first environment! The commands between operating systems are the same on the user side so it doesn’t matter if you’re using Linux, Windows, or Mac in the next steps.


Liked it? Take a second to support AtmoGuy on Patreon!
Become a patron at Patreon!

Comments are closed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑