Van start met Python
Installatie en configuratie
Python, a digital Swiss army knife
Python is een wijd inzetbare scriptingtaal die vooral handig is om snel code op te bouwen. In deze installatiegids wordt getoond hoe je Python kunt installeren en snel van start kunt gaan met een correct Python environment.
Step 1: Install Miniconda
The first thing you need to do is put Miniconda on your computer. Miniconda contains Python and the necessary tools to working with package and environments (more on that in a minute).
You can download Miniconda form the Continuum Analytics website.
Select the Python 3.6 64-bit Windows exe installer and install it like any other Windows program.
Keep all default settings during installation.
Important!:
Write down or remember to location of your Miniconda installation directory, we will need this later on.
For optimal results, use the default: C:\Users\<username>\AppData\Local\Continuum\miniconda3
Step 2: Install the thl_scripts environment
Python is open-source software and has several powerful packages which increase the functionality and provide additional routines. We have made a selection of these packages and thoroughly tested them to ensure that everybody has exactly the same versions on their computer.
The geotech environment contains these packages and can be installed on your computer by doing the following:
Navigate to the location of your Miniconda installation and enter the folder "envs"
Copy the zip file "thl_scripts.zip" from the dataserver or the OneDrive location to your miniconda\envs folder
Unzip "thl_scripts.zip", this may take a few minutes
You should now have a folder \miniconda3\envs\thl_scripts\ Below, you can see what the contents of this folder should be (note that the example is for an environment named geotech).
You should now have a folder \miniconda3\envs\thl_scripts\ It should look exactly like the screenshot on the left.
At this stage, the installation is complete and you can start using Python.
Step 3: Launch Jupyter notebooks
When you want to write a report, you need a word processor. If you just want to type text, you could use Notepad but usually, you will want more functionality to support your writing. The same is true for Python and the Jupyter Notebooks offer a very smooth user experience for working with Python.
You could compare Jupyter to Mathcad, you can create worksheets which are a mix of text and calculations.
To launch Jupyter, you can copy the file "Start Jupyter thl.bat" from the OneDrive location to a folder of your choice, where you want to create a calculation sheet.
You can copy this .bat file into any folder where you want to store Jupyter notebooks with Python code.
Note: The file Start Jupyter thl.bat assumes that your miniconda installation directory is the directory shown in Step 1.
To run the Start Jupyter thl.bat file, double-click it. It will first open a command prompt and then a browser window with the Jupyter landing page (see image on the left).
During your work, you can ignore the command prompt, but don't close it! It is required to execute calculations.
The notebooks you create will be saved in the folder where the Start Jupyter geotech.bat file used for launching Jupyter is located.
Step 4: Open a new Jupyter notebook
To create a new Jupyter notebook, click the button "New" on the top right and select Notebooks>Python [conda env:thl]. If you don't see Python [conda env:thl], just select the default.
This will open a new notebook using the thl environment (note that the screenshot is for an environment named geotech.
The notebook is an interactive editor, allowing you to mix text and code and build transparent, robust workflows.
Important: You should see the geotech environment shown on the top right (see red oval).
To execute your first Python statement, type the code shown on the left in the box and press Shift+Enter. This will print "T-HL loves Python".
Screencast
There is a screencast which shows the installation step-by-step. Click the link to watch it: