1 Download Miniconda
Download Miniconda
for Python version 3 (we would be able to run both Python major versions).
The URL for Miniconda
download is https://docs.conda.io/en/latest/miniconda.html where you should
choose the option for 64-bit Linux.
curro@mint2modesto:~$ cd Downloads curro@mint2modesto:~/Downloads$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh --2020-03-24 19:13:28-- https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8303, ... Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.130.3|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 85055499 (81M) [application/x-sh] Saving to: ‘Miniconda3-latest-Linux-x86_64.sh’
2 Run the installer
curro@mint2modesto:~/Downloads$ bash Miniconda3-latest-Linux-x86_64.sh Welcome to Miniconda3 4.8.2 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>>
Accept the default installation directory, in my case /home/curro/Miniconda3
, and let the installer initialize Miniconda3
.
Open a new terminal and it will have the base environment activated (check your prompt). Update conda
in this new terminal
(base) curro@mint2modesto:~$ conda update conda Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: /home/curro/miniconda3 added / updated specs: - conda The following packages will be downloaded: package | build ---------------------------|----------------- certifi-2019.11.28 | py37_1 156 KB conda-4.8.3 | py37_0 2.8 MB idna-2.9 | py_1 49 KB openssl-1.1.1e | h7b6447c_0 2.5 MB pycparser-2.20 | py_0 92 KB requests-2.23.0 | py37_0 92 KB setuptools-46.1.1 | py37_0 512 KB tqdm-4.43.0 | py_0 56 KB ------------------------------------------------------------ Total: 6.3 MB The following packages will be UPDATED: certifi 2019.11.28-py37_0 --> 2019.11.28-py37_1 conda 4.8.2-py37_0 --> 4.8.3-py37_0 idna pkgs/main/linux-64::idna-2.8-py37_0 --> pkgs/main/noarch::idna-2.9-py_1 openssl 1.1.1d-h7b6447c_4 --> 1.1.1e-h7b6447c_0 pycparser pkgs/main/linux-64::pycparser-2.19-py~ --> pkgs/main/noarch::pycparser-2.20-py_0 requests 2.22.0-py37_1 --> 2.23.0-py37_0 setuptools 45.2.0-py37_0 --> 46.1.1-py37_0 tqdm 4.42.1-py_0 --> 4.43.0-py_0 Proceed ([y]/n)? Downloading and Extracting Packages openssl-1.1.1e | 2.5 MB | ################################################################################################################### | 100% requests-2.23.0 | 92 KB | ################################################################################################################### | 100% conda-4.8.3 | 2.8 MB | ################################################################################################################### | 100% pycparser-2.20 | 92 KB | ################################################################################################################### | 100% idna-2.9 | 49 KB | ################################################################################################################### | 100% setuptools-46.1.1 | 512 KB | ################################################################################################################### | 100% certifi-2019.11.28 | 156 KB | ################################################################################################################### | 100% tqdm-4.43.0 | 56 KB | ################################################################################################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done
3 Create a Python 3
environment.
Now we proceed to create a Python 3
environment.
(base) curro@mint2modesto:~$ conda create --name py3 python=3 Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: /home/curro/miniconda3/envs/py3 added / updated specs: - python=3 The following packages will be downloaded: package | build ---------------------------|----------------- certifi-2019.11.28 | py38_1 157 KB pip-20.0.2 | py38_1 1.7 MB python-3.8.1 | h0371630_1 49.5 MB setuptools-46.1.1 | py38_0 513 KB wheel-0.34.2 | py38_0 51 KB ------------------------------------------------------------ Total: 51.8 MB The following NEW packages will be INSTALLED: _libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main ca-certificates pkgs/main/linux-64::ca-certificates-2020.1.1-0 certifi pkgs/main/linux-64::certifi-2019.11.28-py38_1 ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7 libedit pkgs/main/linux-64::libedit-3.1.20181209-hc058e9b_0 libffi pkgs/main/linux-64::libffi-3.2.1-hd88cf55_4 libgcc-ng pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0 libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0 ncurses pkgs/main/linux-64::ncurses-6.2-he6710b0_0 openssl pkgs/main/linux-64::openssl-1.1.1e-h7b6447c_0 pip pkgs/main/linux-64::pip-20.0.2-py38_1 python pkgs/main/linux-64::python-3.8.1-h0371630_1 readline pkgs/main/linux-64::readline-7.0-h7b6447c_5 setuptools pkgs/main/linux-64::setuptools-46.1.1-py38_0 sqlite pkgs/main/linux-64::sqlite-3.31.1-h7b6447c_0 tk pkgs/main/linux-64::tk-8.6.8-hbc83047_0 wheel pkgs/main/linux-64::wheel-0.34.2-py38_0 xz pkgs/main/linux-64::xz-5.2.4-h14c3975_4 zlib pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3 Proceed ([y]/n)? Downloading and Extracting Packages python-3.8.1 | 49.5 MB | ################################################################################################################### | 100% setuptools-46.1.1 | 513 KB | ################################################################################################################### | 100% wheel-0.34.2 | 51 KB | ################################################################################################################### | 100% certifi-2019.11.28 | 157 KB | ################################################################################################################### | 100% pip-20.0.2 | 1.7 MB | ################################################################################################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done # # To activate this environment, use # # $ conda activate py3 # # To deactivate an active environment, use # # $ conda deactivate
If needed, a Python 2
environment can be created in the same way.
4 Installing software in a given environment
(base) curro@mint2modesto:~$ conda activate py3 (py3) curro@mint2modesto:~$ conda install ipython numpy scipy spyder matplotlib pandas jupyter Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: /home/curro/miniconda3/envs/py3 added / updated specs: - ipython - jupyter - matplotlib - numpy - pandas The following packages will be downloaded: package | build ---------------------------|----------------- attrs-19.3.0 | py_0 39 KB backcall-0.1.0 | py38_0 21 KB . . . y libgfortran-ng-7.3.0 | 1006 KB | ################################################################################################################### | 100% gmp-6.1.2 | 514 KB | ################################################################################################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done
5 Your first jupyter
notebook
You can launch a notebook with the command
(py3) curro@mint2modesto:~$ jupyter notebook [I 19:43:36.145 NotebookApp] Writing notebook server cookie secret to /home/curro/.local/share/jupyter/runtime/notebook_cookie_secret [I 19:43:37.193 NotebookApp] Serving notebooks from local directory: /home/curro [I 19:43:37.194 NotebookApp] The Jupyter Notebook is running at: [I 19:43:37.195 NotebookApp] http://localhost:8888/?token=42d493626e94c6f5c1ae2d7cdcd300075b584cbe20b62f72 [I 19:43:37.196 NotebookApp] or http://127.0.0.1:8888/?token=42d493626e94c6f5c1ae2d7cdcd300075b584cbe20b62f72 [I 19:43:37.196 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 19:43:37.283 NotebookApp] To access the notebook, open this file in a browser: file:///home/curro/.local/share/jupyter/runtime/nbserver-6617-open.html Or copy and paste one of these URLs: http://localhost:8888/?token=42d493626e94c6f5c1ae2d7cdcd300075b584cbe20b62f72 or http://127.0.0.1:8888/?token=42d493626e94c6f5c1ae2d7cdcd300075b584cbe20b62f72 [I 19:43:45.541 NotebookApp] Creating new notebook in [I 19:43:45.572 NotebookApp] Writing notebook-signing key to /home/curro/.local/share/jupyter/notebook_secret [I 19:43:47.232 NotebookApp] Kernel started: 9ab7c66b-92db-4e3e-a137-9900af586546 [I 19:45:47.214 NotebookApp] Saving file at /Untitled.ipynb
By default you can only access notebooks and directories below the folder from which you run the jupyter notebook
command, but not files above this folder. You can alter this default behavior and other jupyter
default config options editing the application config file as in the following example.
You first generate a config file for your notebooks
(py3) curro@mint2modesto:~$ jupyter notebook --generate-config Writing default config to: /home/curro/.jupyter/jupyter_notebook_config.py (py3) curro@mint2modesto:~$ ls ~/.jupyter/ jupyter_notebook_config.py
This file contains the default configuration of jupyter
. In order to create a folder and make this directory the default working directory for our notebooks, you can proceed as follows (not recommended unless you are positive all of your notebooks will be contained in this folder and its subfolders
(py3) curro@mint2modesto:~$ mkdir ~/Python
You should then be able to open the jupyter_notebook_config.py
file in a text editor and modify the default configuration if needed.
6 Your first spyder
session
Spyder
is an IDE aimed mainly at scientific programming with
Python
. Its approach is widely different to the approach followed
in jupyter notebooks
but it has some fundamentals advantages when it
is used in combination with git
. You can launch spyder
with the
command
(py3) curro@mint2modesto:~$ spyder
The first time you launch the application it will offer you the possibility of an interactive tour where its main features are shown.
7 Keeping your Anaconda
install updated
The most important command in this case is
conda update --all
This will update all packages in the current environment. You can also update a selected package or packages (and dependencies) as follows
conda update numpy scipy
As in the install case, this will only affect the current environment.
You can list what are the environments you have created with the command.
$ conda info --envs # conda environments: # base * /home/cfwi/miniconda3 cf1 /home/cfwi/miniconda3/envs/cf1 cf2 /home/cfwi/miniconda3/envs/cf2 py3 /home/cfwi/miniconda3/envs/py3
Let’s assume that we want to remove environment cf2
. We can do so by
$ conda remove -n cf2 --all Remove all packages in environment /home/cfwi/miniconda3/envs/cf2: ## Package Plan ## environment location: /home/cfwi/miniconda3/envs/cf2 The following packages will be REMOVED: _libgcc_mutex-0.1-main ...
You can also rename an environment using the command
conda rename -n old_name new_name
Created: 2023-09-30 Sat 05:02