首页 > 解决方案 > 在 python 上配置包

问题描述

我很好奇这里是否有人能够使用 h5py 库成功访问 NREL 的风数据集,如下所述:https ://github.com/NREL/hsds-examples ?

我在配置 HSDS 时遇到问题。我正在使用 Python 3.7.10 和 Anaconda。这些是列出的步骤:

为此,您必须首先安装 h5pyd:

pip install --user h5pyd

接下来,您需要配置 HSDS:

hsconfigure

并在提示符下输入:

hs_endpoint = https://developer.nrel.gov/api/hsds
hs_username = None
hs_password = None
hs_api_key = 3K3JQbjZmWctY0xmIfSYvYgtIcM3CN0cb1Y2w9bf

如何配置 HSDS?当我在终端中输入“hsconfigure”时,我看到一个错误“找不到命令”。这是因为我使用 pip 下载而发生的吗?

有什么建议吗?我从来不需要在 Python 上配置任何东西,所以我很迷茫,不确定从哪里开始。

标签: pythonpipanaconda

解决方案


我能够通过以下设置运行它:

  1. (可选)MambaForge 基础。Mamba 比 Conda 快,并且在base中工作实际上是一种反模式。

  2. 专用环境中的 Jupyter。

    jupyter.yaml

    name: jupyter
    channels:
      - conda-forge
    dependencies:
      - jupyter
      - nb_conda_kernels
    

    命令

    mamba env create -n jupyter -f jupyter.yaml
    
  3. 专用内核环境中的 HSDS。

    hsds.yaml

    name: hsds
    channels:
      - conda-forge
    dependencies:
      # core requirements
      - python=3.9 
      - ipykernel  # enables use in jupyter
    
      # dependencies and modules used in notebooks
      - h5py
      - pandas
      - scipy
      - pyproj
      - pytz
      - matplotlib
      - seaborn
      - requests
    
      # install h5pyd from PyPA
      - pip
      - pip:
        - h5pyd
    

    命令

    mamba env create -n hsds -f hsds.yaml
    mamba run -n hsds --no-capture-output hsconfigure
    ## follow instructions
    
  4. 克隆 repo 并在其中启动 Jupyter。

    git clone https://github.com/NREL/hsds-examples.git
    cd hsds-examples
    conda activate jupyter
    jupyter notebook
    
  5. 导航到笔记本 (.ipynb),选择hsds作为内核。


推荐阅读