We understand that sometimes you have code or scripts that have been written for older versions of Python or R. We do recommend updating your code to suit the latest version of Python or R, however, if that is not possible you are able to install and run an older version.
Steps to running an older version of Python:
- Open your Python server and from the JupyterLab dashboard click on the Terminal option
- Within the Terminal window run the following command and follow the prompts:
conda create -n py27 python=2.7 ipykernel
- This will create a very basic py27 environment. Note: The ipykernel package is important as it allows the notebook server to use the new conda environment as a notebook kernel.
- Once installation has completed you will be prompted in the Terminal window to activate the new environment using the below command:
source activate py27
- You will then need to wait around 3 minutes until the new environment is detected by JupyterLab (the cloud servers run a check every 3 minutes for new kernels)
- To check for this you need to a) refresh your browser and/or b) open a new notebook and check the top right of the notebook - it should say Environment (conda_py27).
- You can also change kernels within a notebook by clicking on the Environment (conda_py27). This will open the kernel selector and you can select the py36 environment from the drop-down.
- To verify the Python version running you can run the below lines in a cell:
import sys sys.version
- To install additional packages in this new environment either use the notebook with the py27 activated and run !pip install... or use the terminal and run source activate py27 and then use pip or conda to install additional things.
Steps to running an older version of R:
- Repeat the steps as above but replace the initial command with the below:
conda create -n r36 r=3.6.0 r-irkernel
Note: This new R environment can't be used with RStudio. RStudio will always use ecocloud's preinstalled R environment.
It is worth noting that older versions of both Python and R are often not supported and have no updates. For example, Python 2.7 retired in early 2020. Read more about this here. We can offer some assistance in updating your code base to work in the newest environments if need be.
See video walkthrough: