Skip to content

Installation guide (offline)

Eric Einspänner edited this page May 8, 2024 · 3 revisions

Note to participants of our Bootcamp

There is no need to follow any installation process if you are using Google Colab. Instructions below are for setting it up yourself.

Installation instructions

The exercises use Jupyter notebooks. These provide a nice GUI interface to Python. You need to do a few steps:

Installing Jupyter/Python on your Laptop and set-up the Python Bootcamp

For regular off-line use you should consider installing a Jupyter Notebook/Python environment directly on your laptop. This will provide you with reliable off-line access to a computational environment. This will also allow you to install additional code libraries to meet particular needs.

Choosing this option will require an initial software installation and routine updates. For this course the recommended package is Anaconda. Downloading and installing the software is well documented and easy to follow. Allow about 10-30 minutes for the installation depending on your connection speed.

After installing be sure to check for updates before proceeding further. With the Anaconda package this is done by executing the following two commands in a terminal window:

conda update conda
conda update anaconda

Downloading the GitHub Repository as Zip

  1. Open your web browser and navigate to the GitHub repository you want to download. (https://github.com/University-Clinic-of-Neuroradiology/python-bootcamp)
  2. Click on the green "Code" button and select "Download ZIP". This will download the repository as a zip file to your local machine.

Extracting the Zip File

Once the download is complete, navigate to the folder where the zip file was downloaded. Right-click on the zip file and select "Extract All...". Choose a destination folder for the extracted files and click "Extract". This will unzip the contents of the repository into the specified folder.

Navigating to the Folder with Anaconda Prompt

  1. Open the Anaconda Prompt from the Start menu. This will open a command prompt with the Anaconda environment activated.

  2. Use the cd command to navigate to the folder where you extracted the GitHub repository. For example:

    cd path\to\extracted\repository

    Replace path\to\extracted\repository with the actual path to the folder where you extracted the repository.

  3. Once you're in the correct folder, you can proceed with your project-specific commands, such as creating a virtual environment or installing dependencies.

Creating a Virtual Environment

So, let's create a virtual environment to isolate our project dependencies.

Open a terminal or command prompt and execute the following command:

conda create --name myenv python=3.8

Replace myenv with your preferred environment name. This command will create a new virtual environment named myenv with Python 3.8 installed.

To activate the virtual environment, run:

conda activate myenv

Installing Packages from a requirements.txt File

So, let's install packages from a requirements.txt file using pip.

  1. Navigate to your project directory where the requirements.txt file is located.
  2. Activate the virtual environment if you haven't already done so:
conda activate myenv
  1. Install packages from the requirements.txt file using pip:
pip install -r requirements.txt

This command will read the requirements.txt file and install all the specified packages along with their dependencies into your virtual environment.

Verifying Installation

Once the installation is complete, you can verify that the packages are installed correctly by running:

pip list

Conclusion

By following the steps outlined in this guide, you've successfully created a virtual environment using Conda and installed packages from a requirements.txt file using pip. This approach allows you to manage dependencies efficiently and ensure project reproducibility.