0

I tried installing Rasterio library using command- pip install rasterio and also used conda commands in anaconda cmd, both are didn't worked and it's taking too long to install so I aborted the process. Let me know in detail how to install raserio library for python?

I tried with installing GDAL and raterio whl file by using pip commands. It got installed, but when I tried to import module- it's giving me an error saying No module found. Please help to fix this.

Thanks in advance

Thej
  • 1
  • 3
  • it really depends on internet speed. – Ameya Jul 01 '22 at 04:15
  • Hi I installed by using WHL file, it got installed, but while trying to import rasterio, it still giving me an error of No module found!1 – Thej Jul 01 '22 at 05:23
  • Did you install in a seperate environment or something else? The activate the environment and try again – Ameya Jul 01 '22 at 05:41
  • could you please help with the steps, if possible? – Thej Jul 01 '22 at 07:35
  • Sessions launched from [here](https://mybinder.org/v2/gh/LandscapeGeoinformatics/geopython-ut-2019/master?filepath=L4%2Flesson4.ipynb) and served via MyBinder.org work to import rasterio. For those interested on how, they use only conda (mamba actually behind-the-scenes) via this [environment.yml](https://github.com/LandscapeGeoinformatics/geopython-ut-2019/blob/master/environment.yml) configuration file that specifies the conda-forge channel. – Wayne Sep 26 '22 at 18:05
  • `pip install --only-binary :all: rasterio` worked for me; see https://github.com/rasterio/rasterio/issues/2473 – denis Nov 02 '22 at 17:28

1 Answers1

0

I just had the similar problem, and tl:dr the issue for me was multiple environments, like Ameya said. Here's a longer version of Ameya's spot-on answer with steps to diagnose and fix.

Without realizing it, I had two environments going on: my jupyter notebook was running python 3.10 and my global python was running 3.9, and each was looking for site-packages in different locations (/opt/homebrew/Cellar/jupyterlab/3.4.7/libexec/lib/python3.10/site-packages vs /Users//Library/Python/3.9/lib/site-packages).

This happened because I had trouble with getting python and specifically jupyterlab running on Monterey and the only fix for me was using homebrew to manage the packages. Anything I installed with brew from the command line, went into /opt/homebrew/Cellar... etc and could be seen by my jupyter notebook. Anything I used pip install to get from within an open notebook also went onto this path that my notebook could see. But anything I used pip install from the command line to get, went to the path of the global environment's site packages. Then, my jupyter notebook couldn't see them.

You don't mention that you are using jupyter notebook but perhaps something analogous could happen between multiple environments for you.

You can check if this is the case for you by doing the following:

  1. start python from the command line
  2. import sys
  3. run sys.path
  4. start jupyter notebook, or start python from your other environment
  5. same thing, import sys, run sys.path

Are they the same? If not, probably pip is putting your rasterio in other python env site-packages.

To fix, you can either pip install from within your preferred environment, or copy and paste the site packages corresponding to rasterio from one site-packages location to the other.

teb223
  • 13
  • 2