'how to solve rasterio installation problem

When i install rasterio library i get this type of error mentioned below. How to overcome it? Can anyone help me with full procedure. Though i follow the installation instruction given in https://rasterio.readthedocs.io/en/stable/installation.html i couldn't prevent the error.

C:\Python27\Scripts>pip install rasterio
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting rasterio
  Using cached https://files.pythonhosted.org/packages/f7/03/1dcc14b0c77ec4c4ca4bd917527bc41fdbba49f56015d535f3d781c826aa/rasterio-1.0.28.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\python27\python.exe' 'c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'c:\users\user\appdata\local\temp\tmpd49eu2'
       cwd: c:\users\user\appdata\local\temp\pip-install-rm7g58\rasterio
  Complete output (2 lines):
  INFO:root:Building on Windows requires extra options to setup.py to locate needed GDAL files. More information is available in the README.
  ERROR: A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
  ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python27\python.exe' 'c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'c:\users\user\appdata\local\temp\tmpd49eu2' Check the logs for full command output.


Solution 1:[1]

If you are using anaconda, you can use the code below to install rasterio or any other packages showing this type of error with pip installation.

conda install -c conda-forge rasterio

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1