-
Farzaneh-prime authoredFarzaneh-prime authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Lesson 00_Setting up your workspace.html 7.08 KiB
<p style="text-align: justify;">Welcome to part three of the Smart Data coding course "Python and Social Media Geographic Information", where you'll unlock vital spatial coding skills that will empower your journey and open new horizons. To be able to follow through the chapters of this course, a few technical prerequisites must be followed. In detail, we need to install Python, the coding language we will use, Jupyter Lab/Notebook, our IDE (or integrated development environment) of choice, and a few Python libraries along the way, that can be seen as add-ons to what Python can do with our commands.</p>
<p style="text-align: justify;">💡If you are taking this course directly from the NFDI4Earth educational portal, you will work with a dedicated Jupyter Lab workspace that is already set up with all necessary libraries and data. This means you can bypass installing Python or Jupyter locally on your computer. Instead, simply log into the portal, and you’ll be ready to jump right into the coding. However, if you prefer to set up your own environment for practice or future use, follow the instructions below.</p>
<h3 style="text-align: justify;">📖Choosing a path</h3>
<p style="text-align: justify;">When installing Python and Jupyter Lab (and other packages), you can either use your native system or create a<strong> virtual environment</strong>, which gives you the ability to create an isolated environment on your machine from where you can start your projects. The big advantage here is that some libraries have dependencies on what is installed and how – and a virtual environment gives you the ability to install or deinstall everything as you go, or just start over if everything goes south. <strong>It is therefore recommended that a virtual environment be created and the needed libraries installed there</strong>. You can use Anaconda Navigator to do this. It is software you can use to avoid typing commands in a command box but instead manage environments and libraries in an easy-to-use user interface. Visit <a href="https://docs.anaconda.com/navigator/" target="_blank" rel="noopener">Anaconda Navigator</a> and its <a href="https://docs.anaconda.com/navigator/tutorials/manage-environments/" target="_blank" rel="noopener">doc </a>for Managing Environments to get more information on how to set up a virtual environment.</p>
<h3 style="text-align: justify;">📖Import a yml. file to create a virtual environment</h3>
<p style="text-align: justify;">Start Anaconda Navigator, click on Environments in the left tab, then on import, and then select the .yml file for your project. Choose a name for the new environment (this will be the name you need for starting it in the command prompt) and click on import. This will take a while to install (approx. 10 minutes depending on your machine and the .yml file). For this course, <strong>we provide you with a .yml file</strong> (download: <a href="https://git.rwth-aachen.de/nfdi4earth/edutrain/content/extern/analysis-of-urban-transformation-processes/-/raw/main/smart_data.yml?ref_type=heads&inline=false" target="_blank" rel="noopener">smart_data.yml</a>) you can create your venv. In most cases, we advise you to follow this path since fewer issues might occur, watch the video below for a detailed visual guide on these steps.</p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/IAwTkQGwvow?si=SfZhz07aFRh7l7ie" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe></p>
<h3 style="text-align: justify;">📖Setting up a virtual environment</h3>
<ol style="text-align: justify;">
<li>Installing Python: If you set up a virtual environment, you must choose a Python version to run it on. Anaconda Navigator lets you choose while setting up the virtual environment, so install the latest Python version if Anaconda Navigator doesn’t advise you to use another.</li>
<li>Installing Jupyter Notebook or Jupyter Lab on your new venv: When installing Python, open the command prompt by typing “anaconda prompt” in your search bar. Now, activate your new virtual environment by typing “activate *your env name*” into the Anaconda command prompt. When the venv is activated, write “conda install -c conda-forge jupyterlab” in the command box. This will install the jupyter lab library to your venv. You can find more information about how to install Jupyter Lab on the website <a href="https://jupyter.org/install" target="_blank" rel="noopener">jupyter.org/install</a>.</li>
</ol>
<h3 style="text-align: justify;">📖Using your native environment</h3>
<ol>
<li style="text-align: justify;">Installing Python: If you are not using your native environment, download Python on <a href="https://www.python.org/downloads/" target="_blank" rel="noopener">python.org/downloads/</a> if not already installed. Sometimes, libraries and other software do have dependencies on the Python version used. If errors occur, please ensure that the software we use is compatible with your Python version.</li>
<li style="text-align: justify;">Installing Jupyter Lab: When Python is installed, open the command prompt by searching for it by typing “cmd” in your search bar. Write "pip install jupyterlab" in the command box. This will install the jupyter notebook library in your native environment. You can find more information about how to install Jupyter Notebook on the website <a href="https://jupyter.org/install" target="_blank" rel="noopener">jupyter.org/install</a>.</li>
</ol>
<p style="text-align: justify;">💡If you want Jupyter Lab or Jupyter Notebook to open in a particular folder (for example, “D:/”), you can add the <code>--notebook-dir </code>option to your command. This tells Jupyter exactly which folder to use as its starting location. For instance:</p>
<ol>
<li style="text-align: justify;">For Jupyter Lab → <code>jupyter lab --notebook-dir=D:/</code></li>
<li style="text-align: justify;">For Jupyter Notebook → <code>jupyter notebook --notebook-dir=D:/</code></li>
</ol>
<p style="text-align: justify;">Just replace D:/ with the path you’d like to use on your own computer. This ensures that Jupyter starts in that directory instead of the default one<span style="color: #313131; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;">, watch the video below for a detailed visual guide on these steps.</span></p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/xZMtQmtF-3o?si=0tQGE6yCtZJZuJSE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe></p>
<p style="text-align: justify;">Now that you’ve successfully set up your environment and are ready to work with the tools we’ll use throughout the course, great job! You’re all set to dive into the world of spatial coding. Let’s move on to the next chapter and start learning🥳</p>