Ben Mann
Ben Mann

Reputation: 311

Installing OSMnx with Anaconda

I am trying to install the osmnx package in Python 3 on my computer, following the steps outlined here https://geoffboeing.com/2017/02/python-getting-started/. The steps are:

  1. Download miniconda, with the path C:\Anaconda. I am unable to do this as I am using university computers. However, Anaconda is already installed on those computers, with the path C:\Program Files \Anaconda3.
  2. Within the Anaconda Prompt, I tried conda update -n base conda. However, this does not go through because I do not 'have write permission to the target environment' (C:\Program Files \Anaconda3).
  3. I ignored this error, assuming conda was up to date. conda config --prepend channels conda-forge ran fine.
  4. conda create -n ox -c conda-forge osmnx jupyterlab and conda activate ox ran fine. OSMnx and jupyterlab are listed in Anaconda Navigator>Environments>ox>installed.
  5. In the ox environment, I ran jupyter lab, but this gave the following error. I'm sorry for this huge quote, but I don't know how to interpret any of this:
(ox) C:\Users\bm17652>jupyter lab
[I 15:47:48.265 LabApp] Writing notebook server cookie secret to C:\Users\bm17652\AppData\Roaming\jupyter\runtime\notebook_cookie_secret
Traceback (most recent call last):
  File "C:\Users\bm17652\.conda\envs\ox\Scripts\jupyter-lab-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\jupyter_core\application.py", line 268, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
    app.initialize(argv)
  File "<C:\Users\bm17652\.conda\envs\ox\lib\site-packages\decorator.py:decorator-gen-7>", line 2, in initialize
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\notebook\notebookapp.py", line 1679, in initialize
    self.init_webapp()
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\jupyterlab\labapp.py", line 404, in init_webapp
    super().init_webapp(*args, **kwargs)
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\notebook\notebookapp.py", line 1442, in init_webapp
    self.http_server.listen(port, self.ip)
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\tornado\tcpserver.py", line 152, in listen
    self.add_sockets(sockets)
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "C:\Users\bm17652\.conda\envs\ox\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

When I try to open Jupyter Lab from Anaconda Navigator and run import osmnx as ox, I get the error "No module named 'osmnx'".

To me, it seems like Jupyter Lab is not installed properly, or does not have the proper connections with osmnx. Are these errors occurring because:

Upvotes: 5

Views: 10783

Answers (3)

MJ313
MJ313

Reputation: 125

I ran into a similar problem. The solution is to use the right command when installing the omsnx, in the cmd prompt.

Assuming you have activated the environment with conda activate environmentname then you use conda install -c conda-forge osmnx to install the package

Upvotes: 0

jynn
jynn

Reputation: 105

I conda install osmnx and then conda install gdal=2.4.4 and it works!!!

thanks to this link here >>> fiona import issues in python

Upvotes: 0

Hugh_Kelley
Hugh_Kelley

Reputation: 1040

I ran into a similar problem. The solution is to create a new full environment specified for OSMnx. This can be done using

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

you then have to activate that environment using:

(base) C:\Users\User>conda activate ox

after which you can run:

(ox) C:\Users\User>python
>>> import osmnx as ox
>>>

to test for successful installation

Upvotes: 4

Related Questions