{% import macros as m with context %} .. _installation: Installation ======================================================================================================= .. important:: :class: margin If you are taking the course again please see :ref:`takingagain` for how to update. .. admonition:: Need help? If you run into issues following the guide you can always ask in the course :fab:`discord` `Discord <{{ discord }}>`__ (`invitation link <{{ discord_invite }}>`__). In addition, DTU offer campus-wide python help on `pythonsupport.dtu.dk `__, and their Discord channel is often a better place for unusual/platform-specific issues. {{ m.embed('https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=95464764-9ec4-4ec5-a764-b27a0092d838', 'Installation instructions 2025', False) }} {# {{ m.embed('install', 'Installation instructions for windows', False) }} #} {# .. tip:: :class: margin - Don't be discouraged if everything does not install in the first go. Use and the TAs to get help. #} {# .. warning:: :class: margin Python 3.12 is not yet officially supported by libraries we use such as pytorch and gymnasium, however, it seems to work well enough now. #} The course software supports the following python versions: .. note:: :class: margin All tests are known to work for the supported python versions. However, problems are often specific to certain computers/operating systems. :guilabel:`Python 3.8` will **not** work. - :guilabel:`Python 3.9` - :guilabel:`Python 3.10` - :guilabel:`Python 3.11` :bdg-success:`Recommended` - :guilabel:`Python 3.12` :bdg-success:`Recommended` {# :bdg-danger:`Experimental` #} - :guilabel:`Python 3.13` :bdg-warning:`Experimental`{# (see :ref:`python313`) #} This means that the course code and libraries is tested to be compatible on these versions. .. admonition:: Do I have to use Miniconda? :class: dropdown Python comes in different flavors: If for instance you are using :guilabel:`MacOS`, you can either download python from their website (`https://www.python.org `__), or you can use the version of python that is installed on your computer already. So what to do? In reality I would expect nearly any of the supported python versions to work, but on some platforms (:guilabel:`Windows`) you will have to install an external dependencies such as :guilabel:`swig`. This guide recommend that you use the :guilabel:`miniconda`-version of python which provides the python package management tool :guilabel:`conda`. :guilabel:`miniconda` will take care of all external dependencies and to my knowledge provides by far the simplest installation process. Furthermore, all introduction courses at DTU recommend that you use :guilabel:`miniconda` and offer centralized support (`pythonsupport.dtu.dk `__). Regardless of this some may prefer to not use :guilabel:`miniconda`. Here are my comments on different platforms/recommendations: :Windows: On windows, I really recommend that you use :guilabel:`conda` since :guilabel:`swig` is a bit non-trivial to install on windows. :Linux: Linux is very lenient. If you don't like :guilabel:`conda` you can use regular python and :bash:`pip install` the packages, and everything should work. :MacOS: As far as I know this is similar to Linux, but I don't use MacOS myself. Finally, :guilabel:`anaconda` will probably work just as well as Miniconda but it will take up more space. Step 1: If you already have conda and VS Code ---------------------------------------------------------------------------------------------------------------------- If you have already installed :guilabel:`miniconda` and :guilabel:`VS Code` using the guide on `pythonsupport.dtu.dk `__ you probably don't have to do it again. .. note:: :class: margin If you are using an old version of conda and are having problems with numpy please check out :ref:`npcoreissue`. In this case first try to update :guilabel:`miniconda` and python using: {# Here is how you verify that you have installed/activated :guilabel:`miniconda`: - Go to ``__. - Open the recommended guide for your platform (windows, linux, MacOS) - Go to the :menuselection:`Verification` step. - Check that you can do step **1**. Use `this guide `__ to open a terminal if you are in doubt. - Do step **2** (the other steps are not required). Check your python version is between :guilabel:`3.9` to :guilabel:`3.13`. - Open :guilabel:`VS Code` Assuming this works all that remains is to update :guilabel:`miniconda`. Do that by running: #} .. code-block:: bash conda install conda>=25.1.1 conda update python in a `terminal `__. I recommend that you use the terminal in :guilabel:`VS Code`. Then test that you have conda version 25.1.1 or later using: .. code-block:: bash conda --version If this works skip to :ref:`getsource`. Otherwise it is probably best that you :ref:`re-install ` :guilabel:`miniconda`. .. _installpython: Step 2: Install miniconda and VS Code ----------------------------------------------------------------------------------------------------------------------- TL;DR: Follow the guide on ``__. Here is an overview: .. tabs:: .. tab:: Windows - Go to ``__ - Run the command in the first step of the guide in the `terminal `__ - You may have to press enter once while it install VS Code .. tab:: MacOS - Go to ``__. - Under :menuselection:`Step 2`, you can skip item **4** and **5**. To add VS Code to your dock do the following: - Open VS Code from the :guilabel:`Applications folder`, by double clicking the icon. - Add VS Code to your Dock by right-clicking on the icon, located in the Dock, to bring up the context menu and choosing :guilabel:`Options, Keep in Dock`. .. tab:: Ubuntu Linux/command line - Install miniconda by following the steps here: ``__ - Install VS Code using :guilabel:`snap`: .. code-block:: bash sudo apt install snap sudo snap install --classic code - Follow :menuselection:`Step 4` `here `__ to install the VS Code python plugin .. tab:: Generic Linux - Go to ``__ - You can skip :menuselection:`Step 2` {# Step 1: Install an IDE ----------------------------------------------------------------------------------------------------------------------- .. note:: :class: margin I would **not** recommend Spyder since it is quite bad. See :ref:`pycharm` if you prefer to use Pycharm. An IDE is the tool we use to edit code. If you have not used a modern IDE before I recommend that you use VS Code which you may be familiar with from the polytechnical foundation courses: .. tabs:: .. tab:: Windows - Download and install VS Code from ``__ - Use the default settings during install - Don't install python if VS Code suggests that you do so .. tab:: MacOS Full details available from: ``__. - Download Visual Studio Code for macOS from ``__. - Open the browser's download list and locate the downloaded app or archive. - If VS Code was downloaded a :file:`.zip`-file, extract the archive contents. Use double-click for some browsers or select the 'magnifying glass' icon with Safari. - Drag :file:`Visual Studio Code.app` to the :guilabel:`Applications` folder, making it available in the macOS Launchpad. - Open VS Code from the :guilabel:`Applications folder`, by double clicking the icon. - Add VS Code to your Dock by right-clicking on the icon, located in the Dock, to bring up the context menu and choosing :guilabel:`Options, Keep in Dock`. .. tab:: Linux On Ubuntu the simplest way is to use :guilabel:`snap`: .. code-block:: bash sudo apt install snap sudo snap install --classic code For additional distribution-specific instructions please see ``__. #} {# .. _extension: Step 2: Install the Python extension for VS Code -------------------------------------------------------------------------------------------------------------- To enable Python support in VS Code, you must install the Python extension. To do this: - From the :ref:`activity bar `, click on the icon with the four boxes indicated in :ref:`the screenshot `. - This will open a pane. Type **python** in the search field and hit :kbd:`enter` - Install the :guilabel:`Python` extension (top most search hit). It will have :guilabel:`Microsoft` as publisher. #} .. _getsource: Step 3: Download the exercises -------------------------------------------------------------------------------------------------------------- .. warning:: :class: margin You can put the :file:`02465students`-folder any place you like, but once you have completed the following steps you should **not move or rename** the folder for the remainder of the course as this will confuse Python. If you do move or rename the folder, you should re-do :ref:`installpackages`. In this step you will download the course software to your computer. .. tabs:: .. tab:: Download as a :bash:`zip`-file Download the course toolbox as a :bash:`zip`-file: - ``__. - Extract the :bash:`zip`-file to the location where you would like to store the course material. - **Optionally:** rename the folder :file:`02465students-master` to :file:`02465students` for convenience. .. tab:: Download using :bash:`git` Git is a popular tool for code management and collaboration. If you prefer to use git you can clone the source repository using this command: .. code-block:: bash git clone https://lab.compute.dtu.dk/02465material/02465students.git .. note:: If you don't have git, you can download it from: ``_. Accept the recommended default settings during install (on Linux, run :bash:`sudo apt install git`) After these steps you should end up with a folder called: :file:`02465students` containing the source code. {# Step 4: Install Python --------------------------------------------------------------------------------------------------------------------------- .. note:: :class: margin I recommend Miniconda for windows. Miniconda will automatically install the program called :guilabel:`swig` (which is required for gymnasium) and that will save you some troubles. If you don't like miniconda you can still install miniconda manually on windows (use google to find instructions). If you are using miniconda on macos or Linux those should work fine as well. To run Python files, you must have a *Python interpreter* installed. The interpreter is responsible for running (i.e., interpreting) your :file:`.py`-files. .. tabs:: .. tab:: Windows Download and install **Miniconda** from `https://docs.conda.io/en/latest/miniconda.html `__. **Important:** - Make sure to **check** :fa:`check-circle` the option :guilabel:`For this user only` when prompted Then next time you are prompted: - Make sure to **check** :fa:`check-square` the option :guilabel:`Add Miniconda to my PATH variable` - Make sure to **check** :fa:`check-square` the option :guilabel:`Register Miniconda as my default python 3.11` .. tab:: MacOS - From the :ref:`VS Code terminal ` type .. code-block:: bash python3 --version - If you have Python installed, this will print out the version number. If it is between :bash:`Python 3.9` and :bash:`Python 3.13` you should be fine. - Otherwise follow these instructions ``__. .. tab:: Linux (Most linux users) Since there are many linux distributions, you may have to google your way to a solution. However, on Ubuntu, first check if you have python by running: .. code-block:: bash python --version If the version is between 3.9 to 3.13 you should be fine. Otherwise run: .. code-block:: bash sudo apt install -y python3-pip python3.11 python-is-python3 Confirm that :bash:`python --version` works. .. tab:: New linux distributions (Ubuntu 23.04+) The latest linux distributions requires you to use a virtual environment. The steps are a little more complicated, but once you are done, it will not affect how Python works. First, install (or rather, make sure you have) a base version of Python: .. code-block:: bash sudo apt-get update sudo apt-get install python3-venv The virtual environment is a special folder which will contain a separate version of Python. I recommend installing it in your home folder for simplicity as follows: .. code-block:: bash python3 -m venv ~/venv Then whenever you need to use Python in a terminal, type the following: .. code-block:: bash source ~/venv/bin/activate and you can now use Python as normal. When you install packages, they will be put in the :file:`~/venv`-folder. When you install the course software in :guilabel:`VS Code`, you need to select the interpreter located at :file:`~/venv/bin/python`. #} Step 5: Open VS Code ----------------------------------------------------------------------------------------------------------------------------- - Open :guilabel:`VS Code` - Open the folder :file:`02465students` you created before by using :menuselection:`File --> Open Folder...`. Open the folder in the file navigator and press the :guilabel:`Open` button - Start a new terminal using :menuselection:`Terminal --> New Terminal` - Type :bash:`conda` in the command line to check it works. - If this does not work try to restart your computer. - If it still does not work conda is not installed correctly in the previous step. Use google, a TA, or `pythonsupports discord `__ to get help .. _installpackages: Step 6: Install the course software ------------------------------------------------------------------------------------------------------------------------ In the terminal you created in the previous step type: .. code-block:: bash conda env create -f environment.yml .. tip:: :class: margin If you don't like that name :guilabel:`irlcenv` you can change it by editing :file:`environment.yml` and change the line: :code:`name: irlcenv2`. This will create a conda environment called :guilabel:`irlcenv`. Select your environment in VS Code. To do this open the command pallet using :kbd:`ctrl+Shift+P`, type :guilabel:`Python: Select Interpreter`, and select your environment (:guilabel:`irlcenv`) from the list. You can also see/select the environment in the lower right corner of VS Code. .. hint:: You can always `activate `__ an environment in a terminal by typing: .. code-block:: bash conda activate irlcenv Note that if you are re-installing the toolbox in a new location on your computer you will get the error: :bash:`CondaValueError: prefix already exists`. This indicates that the environment already exists. To fix this problem, you should select a new name for the environment (see the tip in the margin) and re-run :bash:`conda env create -f environment.yml`. When you activate the environment you will notice that the terminal begins with :bash:`(irlcenv)`. If this is not the case you should use the command above to re-activate it. You can learn more about environments `here `__. Open a new terminal using :menuselection:`Terminal --> New Terminal`. Check that it says :bash:`(irlcenv)` in the left of the terminal. Finally verify the installation by running this code in terminal: .. code-block:: bash python -c"import irlc; import gymnasium; print(gymnasium.__version__)" If this code prints out :bash:`1.0.0` (or higher) you should be all set {# to the left of the terminal. - The new terminal should display the name of your environment :guilabel:`my_irlc_env` to the left. See step 5 of `install conda in VS Code `__. {# - Install - Navigate to the folder you created in the step :ref:`getsource` step, :file:`02465students` - You can display the current path of the terminal by typing :bash:`cd` (Windows) or :bash:`pwd` on (Mac/Linux). - You change to a subfolder by typing :bash:`cd name_of_the_folder`, or move one folder up by typing :bash:`cd ..`. - Check that you have navigated to the correct folder by verifying that it contains :file:`requirements_pip.txt`. - You can list which files are in the folder by typing :bash:`dir` (Windows) or :bash:`ls` (Mac/Linux). .. tabs:: .. tab:: Windows - See :ref:`conda` for more conda commands or `install conda in VS Code `__ which this guide is based on. - Create a new conda environment by running: .. code-block:: powershell conda create --name my_irlc_env python=3.12 # The name and version is up to you. - Select your environment in VS Code. To do this open the command pallet using :kbd:`ctrl+Shift+P`, type :guilabel:`Python: Select Interpreter`, and select your environment (:guilabel:`my_irlc_env`) from the list. If it does not appear, select :guilabel:`Enter interpreter path..` and navigate to it. - **important:** Open a new terminal using :menuselection:`Terminal --> New Terminal` - The new terminal should display the name of your environment :guilabel:`my_irlc_env` to the left. See step 5 of `install conda in VS Code `__. - Navigate to the :file:`02465students` folder and run: .. code-block:: powershell conda install -c conda-forge --file requirements_conda.txt pip install -r requirements_pip.txt .. tab:: Linux - Run these commands in the VS Code terminal: .. code-block:: bash sudo apt install swig python3-dev build-essential python3 -m pip install -r requirements_pip.txt python3 -m pip install -r requirements_conda.txt .. tab:: MacOS - Run these commands in the VS Code terminal: .. code-block:: bash brew install cmake brew install zlib brew install swig python3 -m pip install -r requirements_pip.txt python3 -m pip install -r requirements_conda.txt .. note:: If you don't have Brew, install it using this guide `https://brew.sh/ `__. Check the output when you run the install commands to see if they exit with an error. Many common problems can be solved using the `pythonsupport.dtu.dk `__ #} .. _updating: Making sure your files are up to date ----------------------------------------------------------------------------------------------------------------------------- {{ m.embed('https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=a04fef38-b830-40eb-9a96-b10301550c3d', 'Updating your files', False) }} To ensure that the course exercises work with the most recent versions of the libraries we use I will upload the exercise code during the course. I have written a small python script to update the files, :gitref:`../irlc/update_files.py`. You can run it like a normal file, or from the terminal: .. code-block:: bash python -m irlc.update_files .. note:: The file will check your version of the toolbox against the most recent version on gitlab. It will then - Replace any files you are missing - Overwrite the **tests** for the weekly exercises and projects It will **not** overwrite your solutions to the exercises and projects. If you may have changed a file and wish to reset it, just delete it from your computer and run :file:`update_files.py` to update. Known Issues ------------------------------------------------------------------------------------------------------------- Even though the installation worked for the TAs and me you might experience problems specific to your system. This guide will try to keep track of common problems and their solution .. attention:: February 2025 update: :class: margin I have subsequently updated the :gitref:`../environment.yml` file to ensure that you get the right version of numpy. I don't anticipate that this problem occurs again but please let me know if it does! Thanks to pythonsupport for help on this issue. .. _npcoreissue: Problem with `numpy core` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you are using an existing version of conda you might get problems involving ``numpy core`` (sorry I don't have the error). This occurs because the current version of numpy is version ``2.0`` (or later) and older versions of conda have been observed to install version ``1.26`` in some cases. To check your current version of numpy run: .. code-block:: powershell python -c"import numpy; numpy.__version__" If this is older than ``2.0.1`` then run .. code-block:: powershell conda install numpy>=2.0.1 Cannot find file ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **You get an error such as:** .. code-block:: bash ModuleNotFoundError: No module named 'irlc.exam.midterm2023a.question_pid' First check that the file you are trying to run exists (in this case :file:`irlc/exam/midterm2023a/question_pid.py`). If this is the case, you probably have two copies of the :python:`irlc`-package, and the file is not located in the one you installed in :ref:`installpackages`. **Solution**: To check where you installed :python:`irlc`, run the following command from the VS Code terminal .. note:: :class: margin on MacOS, assuming you normally run programs with :bash:`python3`, use: :bash:`python3 -c"import irlc; print(irlc.__path__)"` .. code-block:: bash python -c"import irlc; print(irlc.__path__)" On my computer this will print out :python:`['/home/tuhe/Documents/02465students/irlc']`. Then make sure the file you are trying to run is located in this directory, i.e. as :file:`/home/tuhe/Documents/02465students/irlc/exam/midterm2023a/question_pid.py`. Windows ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **This application failed to start because it could not find or load the Qt platform plugin "windows"** Try these commands in the VS Code terminal: .. code-block:: bash pip uninstall pyqt5 conda install pyqt If this fail to work see `this thread `__. .. _pycharm: Linux: If the right-click menu looks bad ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If the right-click menu looks bad (i.e., it is to big etc) you can fix it as follows: - press :kbd:`ctrl+Shift+P` in :guilabel:`VS Code` - Search for and select :guilabel:`Preferences: Open workspace settings` from the drop down. - Under the :guilabel:`User` tab, search and find :guilabel:`Window: title bar style` and change it to :guilabel:`custom`. - Restart VS Code and enjoy that the menus fit on screen. Appendix A: Setting up Pycharm -------------------------------------------------------------------------------------------------------- If you wish to use Pycharm instead of VSCode, this is how I recommend you set it up. To get started follow the previous guide but feel free to skip the bits about install VS Code, obviously. - Install Pycharm community edition - Start pycharm and create a new project. The name can be anything you like such as *02465rl* - The root of the project can be anything -- we are going to fix that later. - Select the interpreter you installed. If you followed the above guides, it should probably be under :guilabel:`System interpreter`. Look under :guilabel:`Conda` from the drop-down menu. - Create project and wait for pycharm to load. Then open settings using :kbd:`ctrl+alt+s` (or use the file menu) - Under :guilabel:`project: ` select :guilabel:`Interpreter` - Check you got the main packages you installed such as gym. If not, select an interpreter from the list. If the python version you installed is not show, use ``show all`` from the dropdown and you can add/configure the one you installed - Under :guilabel:`project: ` select :guilabel:`Project structure` - Select :guilabel:`Add project root`. Navigate to and add the :guilabel:`02465students` folder. - again in the settings dialog, under :guilabel:`Tools` select :guilabel:`Python integrated tools`. Then change :guilabel:`Default test runner` to just :guilabel:`Unittest`. - You are now done. You should be able to run and debug files. Note that pycharm will not allow you to run files while it is indexing your packages (check progress bar in lower right corner) In case Pycharm runs your tests twice (and first time fails) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Recent versions of pycharm use something called Pytest to set up and evaluate the test. Pytest has a bug where it will run the same test twice but in a different way, leading the test to crash in the first go. A way to tell this has happened is to look at the error message and see if it mentions pytest near the beginning. The way to fix that is to disable pytest and use regular python :guilabel:`unittest` instead. This is easy: - Click :guilabel:`File` then :guilabel:`Settings..` - Click :guilabel:`Tools` and select :guilabel:`Python integrated tools` - From the dropbox :guilabel:`Default test runner` select :guilabel:`Unittest` (see screenshot) .. image:: ../../shared/figures/pycharm_testconf.png :width: 500 :alt: Selecting your test runner. This will mean new tests are no longer run by Pytest, but Pycharm has a habit of remembering previous run configurations so if the problem occurs again, go in the top-right corner, click the drop-down menu left of the run-button (see screenshot below) and select :guilabel:`Edit Configurations`. This will open a window with all configurations. From the menu on the left, find all configurations that mention tests, select them, and press the small minus sign to delete them -- don't worry if you delete one too many, pycharm will recreate them. (see screenshot) .. image:: ../../shared/figures/pycharm_testconf2.png :width: 500 :alt: Deleting bad configurations. .. _python312: Appendix B: Python 3.13 -------------------------------------------------------------------------------------------------------- Python 3.13 is the most recent version of python. Although it works fine on the platforms I have tested, it is my experience that the newest version of python can have platform-specific issues with regards to complex packages such as pygame or gymnasium so be on the lookup if you encounter strange errors. I will list problems and solutions here. {# **It is not yet officially supported by gymnasium, pygame and pytorch**, and therefore I recommend that you use python 3.11. If you still wish to use Python 3.12, you should first install the pre-release version of pytorch: .. code-block:: bash pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu and then follow the installation instructions for your system. Using this approach I can run all tests on python 3.12/Linux, but you might experience platform-specific problems where the only solution is to wait for python 3.12 support. #} {# .. _conda: Appendix C: Conda guide ------------------------------------------------------------------------------------------------------------- .. tip:: :class: margin Learn from my mistakes and get in the habit of using conda now and not later. It will save you hours down the line When starting a new project *or* course it is always recommended to create a new virtual environment. We do this to prevent dependency issues down the line when installing new packages. To create a new environment with a specific python version, do the following: .. code-block:: powershell conda create -n python= Recommended version :bash:`=3.10` Pick an appropriate name for the environment like: :bash:`=rl_control` Use the below command to see all current anaconda environments and where they are installed. The currently activated environment is marked with a ``*`` .. code-block:: powershell conda env list Then activate the newly created environment .. code-block:: powershell conda activate env_name In your terminal you should now see :bash:`(env_name)` in front of your current file path. The name given in the parenthesises are indicating the currently activated environment and is also the environmnet where packages will be installed when using :bash:`conda` (recommended) or :bash:`pip`. You can now continue with the provided installation guide. For vscode users ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To ensure that vscode uses the correct virtual conda environment you should always launch vscode from within the anaconda navigator (terminal). This is achieved by running code in the terminal. .. code-block:: powershell code If you wish to open vscode within a specific folder you can run .. code-block:: powershell code Use :bash:`code .` to launch vscode in the current working directly. Deleting environments ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. note:: :class: margin Thanks to Calle for contributing this guide! Since we are installing complete sets of libraries every time we create a new environment over time we may have a bunch of old environment taking up unnecessary space. To delete an environment run the following code: .. code-block:: powershell conda env delete If for some reason this command fails you can also delete the folder manually. Remember that you can use :bash:`conda env list` to show where conda has installed the environment. #} .. _takingagain: Appendix C: If you are taking the course again ---------------------------------------------------------------------------------------------------------------------- The course toolbox is continuously updated and therefore it is important that you have the most recent version of the exercise files. To do this, make a backup of your :file:`02465students`-directory by e.g. renaming it to :file:`02465students-backup`. Then re-do the step :ref:`getsource` to get a fresh copy of the course toolbox which you can call :file:`02465students` again. Most of your solutions to the exercises will work this year, but you should copy-paste your solutions into the updated :file:`.py`-files just to be sure; be particularly vigilant with the projects. Finally you need to update your python packages. If you are using conda, the simplest option is to re-do the step :ref:`installpackages`, which will create a new environment with a fresh copy of all packages. Alternatively, you can update packages manually when/if you encounter problems. To update the :guilabel:`pip` packages use: .. code-block:: bash pip install -r requirements_pip.txt --upgrade To `update a package `__ installed using conda use: .. code-block:: bash conda update conda conda update --all When done check that you got gymnasium version 1.0.0 or later using: .. code-block:: bash python -c"import gymnasium; print(gymnasium.__version__)" .. _noconda: Appendix D: Install the course software without using Conda ----------------------------------------------------------------------------------------------------------------------- Feeling adventurous are we? .. tabs:: .. tab:: Windows - Don't - Install :guilabel:`swig` from ``__ - Download and install python 3.12 from ``__ - Install VS Code, the VS Code python plugin, and to download the course software - Run these commands in the terminal: .. code-block:: bash python -m pip install -r requirements_pip.txt python -m pip install -r .vscode/requirements_conda.txt - Perhaps everything works; if not use google. Conda is not magic so there is a way to fix the problems you might encounter but it will require a bit of reading .. tab:: Linux - Run these commands in the VS Code terminal: .. code-block:: bash sudo apt install swig python3-dev build-essential python3 -m pip install -r requirements_pip.txt python3 -m pip install -r .vscode/requirements_conda.txt .. tab:: MacOS This guide will install python on your build-in system interpreter. - `Install homebrew `__ - Run these commands in the VS Code terminal: .. code-block:: bash brew install cmake brew install zlib brew install swig python3 -m pip install -r requirements_pip.txt python3 -m pip install -r .vscode/requirements_conda.txt .. note:: The main thing to note is that you have to use :bash:`python3` instead of :bash:`python` if you are running files from the command line. For instance: .. code-block:: bash python3 -c"print('hello world')"