The understandinggis
Python environment (including all of the libraries that you need to follow the course) is already installed in the MECD, HBS and ALB computer labs on campus. However, if you would like to install it on your own machine, you need to install it.
There are three approaches that you can use to install the understandinggis
Python environment in Anaconda. If one of them doesn’t work for you, you can simply try the next one.
Before you do anything, you must first ensure that you have Anaconda installed on your machine. If not, install it using these instructions for your operating system:Ensure that you have Anaconda installed on your machine. If not, install it using these instructions for your operating system:
Now you can follow one of these three approaches to installing the understandinggis
Python Environment:
- With Anaconda Navigator
- With the Console (using a specification file)
- With the console (without a specification file)
1. Install via Anaconda Navigator
One simple approach is to use the Anaconda Navigator software that comes with Anaconda:
-
Download the Specification File for the
understandinggis
environment for your operating system. This is a YAML file, which is simply is simply a type of structured text file (you can read it if you open it in Notepad, TextEdit or similar), and in this case it simply contains a list of all of the libraries that Anaconda should install to create theunderstandinggis
environment.- For Windows users, right click on this link, select Save Link As and save the file somewhere on your machine as
understandinggis.yml
. - For Mac users, right click on this link, select Save Link As and save the file somewhere on your machine as
understandinggis.yml
. - For Linux users I have not prepared a file, so you should scroll down to option 3
- For Windows users, right click on this link, select Save Link As and save the file somewhere on your machine as
- Open Anaconda Navigator and select Environments in the bar on the left
- Select Import from the buttons at the bottom
- Set the Name to
understandinggis
and the Specification File to the aboveunderstandinggis.yml
file that you downloaded - Press OK
The understandingis
Python environment will then install on your machine and appear in the Environments List. This means it is installed.
2. Install via Console using a Specification File
Another approach that achieves an identical approach to the above is to install the contents of the specification file using a Console (a command window for your machine).
-
Download the Specification File for the
understandinggis
environment for your operating system. This is a YML file, which is simply is simply a type of structured text file (you can read it if you open it in Notepad, TextEdit or similar), and in this case it simply contains a list of all of the libraries that Anaconda should install to create theunderstandinggis
environment. -
Open the Anaconda Command Prompt (on Windows) or the Terminal (on a Mac) and paste in the following command, then press Enter:
conda env create -f understandinggis.yml
Note: if you saved the yml file with a different name, then you will need to update the command to reflect this.
The understandingis
Python environment will then install on your machine. You can test if it has worked by running this command:
conda activate understandinggis
If (base)
changes to (understandinggis)
on the command prompt, then you know it has worked.
3. Install via Console without a Specification File
If you can’t seem to get the above working for any reason, you can achieve the same thing by installing the software manually. This is less preferable, as you won’t get exactly the same versions of the software as you would using the specification file, but this will only cause issues on rare occasions (e.g. if a library has changed relative to the class instructions), and these issues are generally easily resolved.
Open the Anaconda Command Prompt (on Windows) or the Terminal (on a Mac) and paste in the following command, then pressing Enter:
conda create --name understandinggis --channel conda-forge --override-channels --yes python=3 geopandas rasterio pysal networkx osmnx mapclassify scikit-image matplotlib-scalebar flask openpyxl
Depending on your system and internet connection, this may take a while to install, and might spend some time saying Solving Environment...
- this is fine, just be patient.
Installation Troubleshooting
ModuleNotFoundError
(missing libraries)
If you are having problems with your installation, including if it looked like it worked, but you are now getting errors like this one:
ModuleNotFoundError: No module named 'geopandas'
then it is likely that either:
- You have forgotten to activate the Virtual Environment (likely by opening the wrong version of Spyder - see the instructions in the Week 1 practical)
- the installation was interrupted or otherwise failed
If you are sure that the issue is #2, then you can simply try again, using the same method, or a different one, from the three options above.
If that does not work, there are two more things to try:
1. Try updating the environment
If you are having any problems with your installation, the first thing that you can try is to update it. To do this, open the Anaconda Command Prompt (on Windows) or the Terminal (on a Mac) and paste in the following two commands one by one, pressing Enter each time:
conda activate understandinggis
conda update --update-all
This should update your packages, and add any ones that are missing etc.
Note that you should keep an eye on the output an see if there are any obvious errors. If you get one and you can’t understand / resolve it - feel free to post it on the forum for help!
2. Try reinstalling the libraries
If updating the environment is no help, then it is likely that the installation has not worked properly. In this case, we can try re-installing the libraries.
Open Anaconda Prompt (on Windows) or Terminal (on Mac or Linux) and paste in the following command and press Enter (note that if understandinggis
is already the active environment then you can skip that command).
conda activate understandinggis
conda install --channel conda-forge --override-channels --yes geopandas rasterio pysal networkx osmnx mapclassify scikit-image matplotlib-scalebar flask openpyxl
This will force all of the libraries to re-install, which should hopefully fix any previous errors. Note that if your error is with a specific library (e.g. geopandas
) then you can just re-install that one, which would be much faster than re-installing the whole lot!
3. Try reinstalling the environment
If reinstalling the libraries is no help, then we might need to reinstall the whole virtual environment.
Open Anaconda Prompt (on Windows) or Terminal (on Mac or Linux) and paste in the following lines, pressing Enter each time.
conda deactivate
conda env remove --name understandinggis --yes
conda create --name understandinggis --channel conda-forge --override-channels --yes python=3 geopandas rasterio pysal networkx osmnx mapclassify scikit-image matplotlib-scalebar flask openpyxl
Note that you should keep an eye on the output an see if there are any obvious errors. If you get one and you can’t understand / resolve it - feel free to post it on the forum for help!