我正尝试按照以下说明安装keras-bert
:BERT from R。本教程介绍了如何使用R
从Keras
加载和训练BERT模型。
但是当在Anaconda提示符(Windows)中运行时:
conda install keras-bert
我得到以下错误:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- keras-bert
Current channels:
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
- https://conda.anaconda.org/conda-forge/win-64
- https://conda.anaconda.org/conda-forge/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
我还导航到https://anaconda.org,搜索keras-bert
,但是没有找到用于此搜索的项目。
我也尝试过:
python3 -m pip install keras-bert
我没有得到任何输出:
(base) C:\Users\Standard>python3 -m pip install keras-bert
(base) C:\Users\Standard>
但是当我去检查是否用R命令安装了keras-bert时
reticulate::py_module_available('keras_bert')
我获得了:
[1] FALSE
答案 0 :(得分:2)
由于这需要将PyPI软件包与Conda混合使用,因此the best practice recommendation for this将使用YAML文件创建专用环境。在这里,您可能需要附加的版本约束来实现与本教程兼容的设置,但是此YAML足以让我执行第一步:
bert_env.yaml
name: bert_env
channels:
- defaults
dependencies:
- numpy
- keras
- pip
- pip:
- keras-bert
运行
conda env create -f bert_env.yaml
创建一个名为 bert_env 的环境。
然后我可以在R会话中运行
> reticulate::use_condaenv("bert_env", required=TRUE)
> reticulate::py_config()
# python: /Users/user/miniconda3/envs/bert_env/bin/python
# libpython: /Users/user/miniconda3/envs/bert_env/lib/libpython3.6m.dylib
# pythonhome: /Users/user/miniconda3/envs/bert_env:/Users/user/miniconda3/envs/bert_env
# version: 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 23:06:31) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
# numpy: /Users/user/miniconda3/envs/bert_env/lib/python3.6/site-packages/numpy
# numpy_version: 1.18.5
> reticulate::py_module_available("keras_bert")
# [1] TRUE
> tensorflow::tf_config()
# TensorFlow v2.0.0 ()
# Python v3.6 (~/miniconda3/envs/bert_env/bin/python)
这都是在 osx-64 平台上运行的,因此 win-64 所下拉的版本可能会有所不同。最后,这主要应该是tweaking the YAML的问题。