Installing Anaconda and R on Debian
Some time ago, I took The Open University module M348. This module teaches R; we had a virtual server, which we ran on Docker, and then accessed jupyter notebooks with R kernel via web browser.
I decided that, to brush up my R skills, I need to install R on my server. But how to go about it? A fellow student advised to install Anaconda, which would contain jupyter notebooks, R, and other things.
Having installed Debian 13 recently on my server, I tried and googled Install Anaconda on Debian 13 but did not find any specific instructions for my system (unlike for Debian 11, which I had previously but which is now becoming obsolete). So I proceeded using the Anaconda Installing instructions for Linux from the Anaconda website.
I am downloading and running the installation as a user, not as root.
First I needed to go to Anaconda repository and download the installation file according to my architecture.
My virtual server is run by my provider on their platform, so what is my architecture then? Running the following command:
uname -m
gives me the answer: x86_64
Now I can choose and download the appropriate installer file, concatenating the path to the Anaconda archive and the file name into one wget command:
wget https://repo.anaconda.com/archive/Anaconda3-2025.12-1-Linux-x86_64.sh
and then run it in shell exactly as the video advises:
bash ./Anaconda3-2025.12-1-Linux-x86_64.sh
However, when it says “when presented with the option to initialise conda whenever you open a new shell and to recognise conda commands automatically”, I choose to say “no”, as I do not want every shell I ever run to have conda activated and my shell prompt to have unrelated stuff prepended to it when I am not going to use conda.
I am then following the “Manual shell initialization” instructions and run:
source anaconda3/bin/activate
conda init --all
only to find out, that the latter command does exactly what I did not want and installs conda activation into .bashrc file to be executed whenever a new shell is started. Fortunately, it can be easily undone with
conda init --reverse --all
and for good measure
conda config --set auto_activate_base false
From now on, in every shell in which I want to use Anaconda, I will have to run this command first to activate conda:
source anaconda3/bin/activate
Once done, I will see (base) prepended to my command prompt to signalise the active conda environment.
To install R, I run the following:
conda config --add channels r
conda install r-base
From now on, I can access R console from any shell in which conda has been activated by simply typing:
R
However, I want to run R in jupyter notebooks in a (graphical-interface) web browser! Therefore I need to install jupyter notebooks, which,
I am being told, are dependent on python, and I also need to install R kernel for jupyter notebooks, so I run:
conda install anaconda::python
conda install anaconda::jupyter
conda install r-irkernel
(Interestingly, the install command for jupyter tells me that all packages are already installed.)
Now, whenever I want to work with jupyter notebooks with R on my local (Windows) machine, I first need to launch the jupyter notebook server on my remote Linux server, which has Anaconda; to do this, I need to run the following command in a shell with activated conda:
jupyter notebook --no-browser --port=8080
As the jupyter server starts, it gives lots of interesting messages but the most important is the URL to access the server from a browser. It will look like this:
http://localhost:8080/tree?token=long_hexadecimal_number
Then I need to launch command prompt on my local machine and run the following command to activate port forwarding from my local machine to the Linux server:
ssh -L 8080:localhost:8080 my_username@my.server.address
Then I will be prompted for my password for my username on my server and then the ssh connection is established and port forwarding is activated (I am not sure whether ssh is part of standard Windows installation or this works just because I have putty on my Windows machine.)
Now I can paste the above URL (with token) to the address bar of my local browser on my Windows machine (although it says localhost, the port forwarding will forward the traffic to my Linux server) and yay! I can browse jupyter notebooks and use R :)
The tree I see in the browser is apparently rooted in my home directory on the remote server.
Comments
No comments.