【问题标题】:osmNX in Google ColabGoogle Colab 中的 osmNX
【发布时间】:2020-01-08 13:37:49
【问题描述】:

出于我的目的,我需要 Google Colab 中的 osmNX

以前有人做过吗?我使用以下命令:

!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

命令:

!conda info --envs

表示环境创建成功。

当我运行命令时:

!conda activate ox

错误显示:

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'.

命令

!conda init bash

没有效果。

感谢您的帮助

【问题讨论】:

    标签: osmnx


    【解决方案1】:

    !apt-get -qq install -y libspatialindex-dev && pip install -q -U osmnx 将 osmnx 导入为 ox ox.config(use_cache=True, log_console=True)

    你可以使用这个命令!

    【讨论】:

      【解决方案2】:
      !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
      

      我根据此链接https://github.com/gboeing/osmnx/blob/main/requirements.txt 中提供的要求安装了相应的软件包,到目前为止它已在我的应用程序中运行,希望它也适用于您。

      或者,类似于另一个答案,您可以使用下面的代码,在https://stackoverflow.com/a/65378540/18403512

      !apt install libspatialindex-dev
      !pip install osmnx
      

      【讨论】:

        【解决方案3】:

        答案类似于在任何 docker 或外部服务器上运行 osmnx。 我试过了,差不多就到了,也许有人可以帮助完成它。

        让我们从基本的osmnx 安装开始:

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

        然后,让我们看看如何在远程 docker 上做到这一点,例如travis CI(工作样本.travis.yml 来自我的一个仓库):

         - 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
        

        那我们不妨看看如何在colab中有conda并使用这个sn-p:

        %%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
        

        最后归结为 this 几乎可以工作的笔记本,基于 this 帖子。

        在环境之间切换不起作用,因此!conda env list 返回ox 作为环境之一,但激活它失败:

        !conda activate ox
        

        加注:

            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'.
        

        【讨论】:

          猜你喜欢
          • 2021-03-30
          • 2020-02-04
          • 2021-07-22
          • 2021-08-22
          • 2018-06-25
          • 2019-11-08
          • 1970-01-01
          • 1970-01-01
          • 2019-04-01
          相关资源
          最近更新 更多