【FATE联邦学习debug】 No module named ‘federatedml‘
创始人
2024-05-30 03:45:18
0

直接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/pythonexport FATE_LOG_LEVEL=DEBUG
export FATE_PROFILE_LOG_ENABLED=0
export EGGROLL_LOG_LEVEL=INFOvenv=/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,应该也行,但是你的代码编辑器大概率还会报错,但是运行是可以运行的。

如果还想代码编辑器不报错,你可以找找你代码编辑器的关于编辑器环境变量的设置。

相关内容

热门资讯

中证A500ETF摩根(560... 8月22日,截止午间收盘,中证A500ETF摩根(560530)涨1.19%,报1.106元,成交额...
A500ETF易方达(1593... 8月22日,截止午间收盘,A500ETF易方达(159361)涨1.28%,报1.104元,成交额1...
何小鹏斥资约2.5亿港元增持小... 每经记者|孙磊    每经编辑|裴健如 8月21日晚间,小鹏汽车发布公告称,公司联...
中证500ETF基金(1593... 8月22日,截止午间收盘,中证500ETF基金(159337)涨0.94%,报1.509元,成交额2...
中证A500ETF华安(159... 8月22日,截止午间收盘,中证A500ETF华安(159359)涨1.15%,报1.139元,成交额...
科创AIETF(588790)... 8月22日,截止午间收盘,科创AIETF(588790)涨4.83%,报0.760元,成交额6.98...
创业板50ETF嘉实(1593... 8月22日,截止午间收盘,创业板50ETF嘉实(159373)涨2.61%,报1.296元,成交额1...
港股异动丨航空股大幅走低 中国... 港股航空股大幅下跌,其中,中国国航跌近7%表现最弱,中国东方航空跌近5%,中国南方航空跌超3%,美兰...
电网设备ETF(159326)... 8月22日,截止午间收盘,电网设备ETF(159326)跌0.25%,报1.198元,成交额409....
红利ETF国企(530880)... 8月22日,截止午间收盘,红利ETF国企(530880)跌0.67%,报1.034元,成交额29.0...