乐趣区

关于算法:FATE联邦学习debug-No-module-named-‘federatedml‘

间接 pip install federatedml 是无奈找失去这个库的。
这个的起因是环境变量的事件,因为在部署文档中,自身提醒咱们要更新一些环境变量,如果不 export 那些变量,上面的 fate_test 其实也是无奈测试胜利的。

关上bin/init_env.sh,其内容如下

#!/bin/bash

#
#  Copyright 2019 The FATE Authors. All Rights Reserved.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

fate_project_base=$(cd `dirname "$(realpath"${BASH_SOURCE[0]:-${(%):-%x}}")"`; cd ../;pwd)
export FATE_PROJECT_BASE=$fate_project_base
export FATE_DEPLOY_BASE=$fate_project_base
export EGGROLL_HOME=
export PYTHONPATH=/root/Downloads/standalone_fate_install_1.10.0_release/fate/python:/root/Downloads/standalone_fate_install_1.10.0_release/fateflow/python

export FATE_LOG_LEVEL=DEBUG
export FATE_PROFILE_LOG_ENABLED=0
export EGGROLL_LOG_LEVEL=INFO

venv=/root/Downloads/standalone_fate_install_1.10.0_release/env/python/venv
export JAVA_HOME=/root/Downloads/standalone_fate_install_1.10.0_release/env/jdk/jdk-8u345
export PATH=$PATH:$JAVA_HOME/bin
source ${venv}/bin/activate

能够看到这个库自身在下载的 FATE 包里

那接下来其实能够给 conda 的 python 解释器增加环境变量,如何做?
先查看下以后的 python 解释器的门路echo $PATHecho $PYTHONPATH$,因为我应用的是 conda 虚拟环境,我就应用 conda 自带的虚拟环境的环境变量工具增加上 init_env 那两个门路就行了

init_env 文件想 export PYTHONPATH

export PYTHONPATH=/root/Downloads/standalone_fate_install_1.10.0_release/fate/python:/root/Downloads/standalone_fate_install_1.10.0_release/fateflow/python

那用 conda 的话就间接

conda-env config  vars set PYTHONPATH=/root/Downloads/standalone_fate_install_1.10.0_release/fate/python:/root/Downloads/standalone_fate_install_1.10.0_release/fateflow/python

输出后,提醒 To make your changes take effect please reactivate your environment
这样就能够了。

如果你不必 conda,你也能够间接跟文件里的那样间接输出 “
export PYTHONPATH=/root/Downloads/standalone_fate_install_1.10.0_release/fate/python:/root/Downloads/standalone_fate_install_1.10.0_release/fateflow/python“,应该也行,然而你的代码编辑器大概率还会报错,然而运行是能够运行的。

如果还想代码编辑器不报错,能够 在 vscode 的 python 插件里的 extra path setting 里退出 federatedml 的目录。能够参考自己的答复:https://segmentfault.com/q/1010000043514241/a-1020000043868000

退出移动版