Reputation: 17
For my purposes I require osmNX in Google Colab
Has anyone done this before? I use the following commands:
!wget https://repo.anaconda.com/archive/Anaconda3-2019.07-Linux-x86_64.sh && bash Anaconda3-2019.07-Linux-x86_64.sh -bfp /usr/local
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages')
!conda config --prepend channels conda-forge
The command:
!conda info --envs
Shows that the enviroment is created succesfully.
When I run the command:
!conda activate ox
The error is displayed:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
The command
!conda init bash
has no effect.
Thanks for the help
Upvotes: 2
Views: 2921
Reputation: 21
!pip install geopandas== 0.10.0
!pip install matplotlib==3.4
!pip install networkx==2.6
!pip install numpy==1.21
!pip install pandas==1.3
!pip install pyproj==3.2
!pip install requests==2.26
!pip install Rtree==0.9
!pip install Shapely==1.7
!pip install osmnx
I installed the respective packages based on the requirements provided in this link https://github.com/gboeing/osmnx/blob/main/requirements.txt , it has worked in my application so far, hope it works for you too.
Alternatively, similar to another answer, you can use the code below, found in https://stackoverflow.com/a/65378540/18403512:
!apt install libspatialindex-dev
!pip install osmnx
Upvotes: 2
Reputation: 1220
The answer would be similar to running osmnx
on any docker or external server.
I tried it and almost got there, maybe someone can help make it complete.
So let's start with the basic osmnx
installation:
conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx
Then, let's look at how can this be done at remote docker, e.g. travis CI (working sample .travis.yml
from one of my repos):
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
- conda config --prepend channels conda-forge
- conda create -n ox --strict-channel-priority osmnx
- conda activate ox
Then we may take a look at how to have conda in colab and use this snippet:
%%bash
MINICONDA_INSTALLER_SCRIPT=Miniconda3-4.5.4-Linux-x86_64.sh
MINICONDA_PREFIX=/usr/local
wget https://repo.continuum.io/miniconda/$MINICONDA_INSTALLER_SCRIPT
chmod +x $MINICONDA_INSTALLER_SCRIPT
./$MINICONDA_INSTALLER_SCRIPT -b -f -p $MINICONDA_PREFIX
which then finally boils down to this almost working notebook, based on this post.
What is not working is switching between environments, so !conda env list
returns ox
as one of environments, yet activating it fails:
!conda activate ox
raises:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
Upvotes: -1
Reputation: 21
!apt-get -qq install -y libspatialindex-dev && pip install -q -U osmnx import osmnx as ox ox.config(use_cache=True, log_console=True)
you can use this command !
Upvotes: 2