0

I downloaded osmnx via conda using the code:

conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx

This comes from the osmnx documentation: https://osmnx.readthedocs.io/en/stable/

I can see the module has downloaded because in the Anaconda Prompt I can type conda activate oxand it works. However when I go into my jupyter notebook and type

import osmnx as ox

I get the following error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-11-7e05e48535cd> in <module>
----> 1 import osmnx as ox
      2 
      3 

ModuleNotFoundError: No module named 'osmnx'

Please advise as to what I can do. Thanks

smeesn
  • 21
  • 1
  • 4
  • Make sure you have Jupyter configured to use Conda envs, e.g., see: https://stackoverflow.com/a/43197286/570918 That is, make sure to install `ipykernel` in the **ox** env and `nb_conda_kernels` in whatever env has your Jupyter installed (you only need one; for most it is **base**). Launch Jupyter from the latter env activated (likely it's **base**, not **ox**), then select the **ox** env as the kernel for a Jupyter notebook. – merv Jan 06 '20 at 08:02
  • Sorry for the basic question, but I assume I need to type “conda install nb_conda_kernels” and “conda install ipykernel” in the Anaconda prompt. Is that right? It seems like the env directory must be typed here “conda install [env directory] ipykernel” and I’m not sure how to find the name of the directory. Can you advise? – smeesn Jan 06 '20 at 16:15
  • No problem. `conda install -n base nb_conda_kernels` and `conda install -n ox ipykernel`. Then `conda activate base` and `jupyter notebook`. You should then see the option to use **ox** as a kernel in your Jupyter notebooks. – merv Jan 06 '20 at 16:56

1 Answers1

6

In your terminal, run:

conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx jupyterlab
conda activate ox
python -m ipykernel install --user --name ox --display-name "Python (ox)"
jupyter lab

This installs OSMnx and JupyterLab into a conda environment called ox, activates the environment, installs an ipython kernel in the environment, then launches JupyterLab.

See also

gboeing
  • 5,691
  • 2
  • 15
  • 41