Installing the Anaconda 2020-07 Python Distribution with Spyder 4.1.4 on Linux Ubuntu 20.04, Fedora 32 and Mint 20

Installation Video

Uninstalling Kite and Anaconda

Before installing Anaconda, you should remove any old Kite and Anaconda installation to prevent conflicts. Skip this section if on a clean install. Open up files and go to your Home folder:

Select View and then Show Hidden Files:

Uninstalling Kite

Go to the .local folder:

Go to the share subfolder:

Go to the Kite subfolder:

Right click uninstall and rename to uninstall.sh:

Right click an empty space in the folder and select open in terminal:

Type in:

bash uninstall.sh

Close the Terminal.

Uninstalling Anaconda

Delete the following folders anaconda3, .anaconda, .cache, .conda, .ipython and .kite. Also delete the .condarc file:

Next go to the .config folder:

Delete the Kite, matplotlib and spyder-py3 folders:

Return to the Home folder and right click the .bashrc file and select Open with Text Editor:

Press [Ctrl] + [ f ] to open up find and search, look for conda. If the search results come up positive delete the conda initalize:

Then save the file:

You may wish to hide the hidden files again:

The old installation of Anaconda is now uninstalled:

Installation

Installing Anaconda

Go to the Anaconda website:

Select Download:

Download the Linux 64 Bit installer.

Select Save File and then OK:

Go to your Downloads folder, right click an empty space and select Open in terminal:

Type in the following:

bash Anaconda3-2020.07-Linux-x86_64.sh

Then press [↵]

Note the installer may be updated so ensure the date matches that of the standalone installer, you can copy and paste the file name into the console:

Hold down [↵] to scroll through the license agreement.

Then type in:

yes

And then press [↵] to accept the agreement and proceed with the install.

Type in [↵] to proceed with the default location:

Type in:

yes

Then [↵] to run conda init.

Anaconda is now installed:

Installing Kite

It is recommended to install Kite here as this will save time during the initial launch of Spyder 4.

Type in:

bash -c "$(wget -q -O - https://linux.kite.com/dls/linux/current)"

Then press [↵]:

Then press [↵] to proceed:

Kite is now installed:

Close the terminal before using anaconda.

Updating Anaconda Navigator

The Anaconda Navigator expects Ubuntu 20.04 or Fedora 32 and gives the following error when a different linux distribution such as Linux Mint 20 is used:

UnboundLocalError: local variable 'DISTRO_NAME' referenced before assignment

Unfortunately this error is carried over from the Standalone 2020-02 and still exists in the 2020-07 standalone installer.

To resolved this we need to update the Anaconda Navigator. To update the Anaconda Navigator type in:

conda update anaconda-navigator

Then press [↵]:

Type in

y

Then [↵] to proceed with the update.

Now that this is updated, the Anaconda installation and Anaconda navigator should work correctly on Linux Mint:

Launching the Anaconda Navigator

Close and open any terminal windows.

To launch Anaconda navigator type in:

anaconda-navigator

You can then launch a variety of IDEs such as Spyder or JuypterLab:

Spyder

Launch Spyder 4 from the Anaconda Navigator:

Spyder 4 should launch:

Check Dependencies

Before using Spyder, it is worthwhile to check its dependencies. Go to help and then Dependencies:

They should all be ticked:

High DPI Settings and Spyder Light Theme

Select Tools and then Preferences:

If you have a high resolution screen. Select General and Enable auto high DPI scaling.

Select Appearance. Under Syntax Highlighting Theme change Spyder Dark to Spyder:

Select Apply:

Select yes to restart Spyder

Running a Script for the First Time and Accessing Variables from within the Console

Let's create a variable:

a=1

We can then select the run button:

At first launch, you will be given the run settings. If you want to access variables from the console in a script. Check "Run in console's namespace instead of an empty one", this was enabled by default in Spyder 3 and is disabled by default in Spyder 4 causing some confusion.

If you don't have this setting enabled the script won't be able to access variables created from earlier scripts or from the console. Here a is present in the variable explorer but the script cannot find it:

These settings can also be accessed by selecting Tools then Preferences:

The run tab shows the settings above:

Note the settings will apply only for newly created scripts not existing scripts, so attempt this with a new script.

Plot Settings

We can put together a very basic test script to create a plot:

import numpy as np
import matplotlib.pyplot as plt
x=np.arange(start=0,stop=10,step=1)
y=np.arange(start=0,stop=10,step=1)
plt.figure()
plt.clf()
plt.plot(x,y)
plt.show()

By default plots will display inline within the plots pane.

The backend can be changed to automatic in order to plot a graph in its own dedicated window by typing the following in the console:

%matplotlib auto

It can also be reverted to inline using:

%matplotlib inline

This change will be made only for the current session and will revert to a default setting once the kernal has been restarted. To change the default setting, go to Tools and Preferences:

To the left hand side, select IPython console. Select the graphics tab. Change the backline to either automatic or inline:

Select Apply:

JupyterLab

JupyterLab is another IDE which is browser based.

File Explorer

Select the folder you want on the left left hand side menu. In this case Documents. Compatible files can be opened using this left hand side menu.

To the right hand side a Launcher is opened as a tab to the right hand side. From the launched we can create a new Text File, Markdown File or new Notebook.

Text File

From the launcher select Text File:

A new text file called untitled.txt will be opened. Note that this is automatically saved to the Documents folder which is the directory opened to the left hand side:

The file can be renamed by right clicking the tab or the file name within the File Explorer and selecting rename:

In this case I will rename it TestText.txt:

The file is renamed. A new tab can be created by opening another file or adding an additional launcher:

Markdown File

Let's have a look at a MarkDown File. This is essentially a Report File. It acts like a Text File but the Text can be formatted.

Select Markdown File:

Then right click an empty space in the file and select Show Mardown Preview:

# Heading 1
Example Text.
## Heading 2 Bold and Italic
Example Text in **bold**, *italic* and ***bold-italic***.
Strike through ~~this~~.
### Heading 3 List
* Apples
* Bananas
* Grapes


1. Apples
2. Bananas
3. Grapes

* Apples

* Bananas

* Grapes

# Special Characters

\#

\*

\-

\\


# Mathematics
To use an inline equation enclose in \*(equation)\*.

Example Text with inline equation $f\left(x\right)$

To use a display equation enclose in \*\*(equation)\*\*.

Display Equation
$$f\left(x\right)=a_0+\sum_{n=1}^{\infty}\left(a_n\cos{\frac{n\pi x}{L}}+b_n\sin{\frac{n\pi x}{L}}\right)$$

# Link
[Google](https://google.co.uk)

# Code
This code will
```
print('Hello World')
```
print the string 'Hello World'
# Horizontal Separator
---

The file name can be renamed by right clicking the tab and selecting rename:

Then inputting the desired name and then selecting Rename:

The file is now renamed:

Image files can also be added to the Markdown File. The image should be stored in the same folder as the MarkDown File:

![img1](img1.png)

The text within the square brackets is an optional title and can be left blank.

A table can also be generated using the following syntax:

| A | B | C | D |
| -: | :- | :-: | --- |
| apple | banana | carrot | dragon fruit |
| avocado | blueberry | cucumber | dew berry |
| apricot | blackberry | clementine | |

The 0th row is the heading names.

The 1st row is the alignment options (align right, left, center and left with a center heading).

NoteBook File

A NoteBook file consists of a series of cells that can be MarkDown, Code or Raw (Text). Open a new Launcher and select a new Python 3 Notebook:

The currently selected cell is highlighted in Blue to the left hand side. In this case I will set the cell to a MarkDown cell and create a Heading:

Then Run:

When I run this the cell displays as a heading (it can be edited again by double clicking it).

A new cell is created, this time I will leave it as Code. The Code can be ran:

When the code is ran a number displays denoting the order the cells were ran in. This is important when cells are dependent on earlier cells. For example if we create other cells:

The Code cells can be ran in any order i.e. it doesn't need to be ran from top to bottom however if the code of one cell requires the code to run in another cell before hand for example in the case of variable assignment errors will display:

If the assignment code cell is ran before the display code cell, the code works:

Code in the cells can be modified and ran again.

In this case we are asking to display a lot of data. We can right click the left hand side bar of the cell which is highlighted blue and we can enable or disabling scrolling for the output cell:

We can create x and y data and test plotting using the same code as we used in Spyder 4. JupyterLab (without plugins) plots figures inline i.e. making them images:

The cell that creates the inline figure can be reran to update the figure however:

Typing a [↹] gives auto-complete options:

Typing [⇧]+[ ↹ ] will give the docstring which gives more details about the input arguments of a function:

Getting Started with Python

This particular guide is focused only on installation along with some checks to make sure the IDEs are working correctly.

I recommend using the Spyder 4 IDE for learning Python because it has a Variable Explorer (JupyterLab doesn't have one without third party plugins and even the one with third party plugins is way behind that of Spyder). JupyterLab is better for reports.

I would recommend returning back to JupyterLab once you have a handle on the following fundamentals. I cover these using the Spyder IDE:

And a handle on the numeric python (numpy) library, the plotting library (matplotlib) and the python and data analysis library (pandas) which are the most commonly used Python libraries in Data Science.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.