Many of the projects on my github require setting up its own conda virtual environment. Moreover, many python projects work with the geospatial stuff, so many system-wide dependencies have to be installed for the python geospatial libraries to work normally. This gist covers a typical workflow that needs to be executed, if it's your first time using a geospatial python-written project inside in a virtual environment:
-
Install GDAL:
On Ubuntu and Debian, it is fairly easy:
sudo add-apt-repository ppa:ubuntugis-unstable
sudo apt-get install gdal-bin
Otherwise, there are plenty of internet resources that cover installing GDAL, e.g. this one.
-
Install miniconda:
32 bit:
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86.sh --no-check-certificate && bash Miniconda2-latest-Linux-x86.sh
64 bit:
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh --no-check-certificate && bash Miniconda2-latest-Linux-x86_64.sh
-
Compliling non-pure Python dependencies on Windows also requires C++ compilers, so in case of installation errors, make sure you have installed Visual C++ Build Tools package
-
If a project requires Python 2, double check also for Visual C++ 2008 Service Pack 1 and Visual C++ Compiler for Python 2.7
-
download and install Anaconda or Miniconda. Make sure you add the
..\Anaconda\scripts
(or so) to your PATH so thatconda
is going to be a recognized command in your terminal.
Once you have installed conda and created a new dedicated virtual environment my_env, you have to populate it with needed Python libraries. Usually this is done by activating a virtual environment and calling conda install *library*
or pip install *library*
. Unfortunately, on Windows, many complex Python libraries aren't ready for such a simplicity yet.
-
The best way to install bit more specific Python libraries on Windows is by downloading a .whl file from the famous Gotche's unofficial Windows binaries for python packages. In order to use libraries, such as Geopandas, you have to manually download and install the following files, corresponding to your version of Python and OS (32bit or 64bit):
-
Acitvate the virtual environment that you want to populate these libraries with with:
activate my_virtual_env
-
Install downloaded .whl files by
pip install *.whl
. Make sure you move to the download folder so you won't have to worry about absolute paths of wh files. Use tab for names autocomplete. -
Remember to use this technique every time that normal
pip install *
orconda install *
won't do it's job. -
Add the path to GDAL (something like C:\Anaconda\Lib\site-packages\osgeo) to the Windows PATH environment variable