ImportError: cannot import name ‘backend‘ 问题排查

python 执行脚本,root用户正常,切换其他用户报错:

Traceback (most recent call last):
  File "/app/pyjobs/onlineMiningServers/onlineFrameServer/modelService.py", line 11, in <module>
    import msRegion,msMaster_tcp2http,msMasterHttp,msMaster,msRegionHttp
  File "/app/pyjobs/onlineMiningServers/onlineFrameServer/msRegion.py", line 13, in <module>
    from keras import backend as K
ImportError: cannot import name 'backend'

排查后发现Python模块目录权限有问题,其他用户无法读取到安装的模块,修改权限命令如下:

chmod -R 755 /usr/local/Python-3.6.1/lib/python3.6/site-packages/*

修改权限后其他用户执行python 脚本正常

{ "name": "ImportError", "message": "cannot import name 'backend_agg' from 'matplotlib.backends' (C:\\Users\\游箫箫\\AppData\\Roaming\\Python\\Python39\\site-packages\\matplotlib\\backends\\__init__.py)", "stack": "--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[9], line 1 ----> 1 get_ipython().run_line_magic('matplotlib', 'inline') 2 import numpy as np 3 import pandas as pd File d:\\Huawei Share\\Huawei Share\\envs\\env_name\\lib\\site-packages\\IPython\\core\\interactiveshell.py:2414, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth) 2412 kwargs['local_ns'] = self.get_local_scope(stack_depth) 2413 with self.builtin_trap: -> 2414 result = fn(*args, **kwargs) 2416 # The code below prevents the output from being displayed 2417 # when using magics with decodator @output_can_be_silenced 2418 # when the last Python token in the expression is a ';'. 2419 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False): File d:\\Huawei Share\\Huawei Share\\envs\\env_name\\lib\\site-packages\\IPython\\core\\magics\\pylab.py:99, in PylabMagics.matplotlib(self, line) 97 print(\"Available matplotlib backends: %s\" % backends_list) 98 else: ---> 99 gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui) 100 self._show_matplotlib_backend(args.gui, backend) File d:\\Huawei Share\\Huawei Share\\envs\\env_name\\lib\\site-packages\\IPython\\core\\interactiveshell.py:3585, in InteractiveShell.enable_matplotlib(self, gui) 3564 def enable_matplotlib(self, gui=None): 3565 \"\"\"Enable interactive matplotlib and inline figure support. 3566 3567 This takes the following steps: (...) 3583 display figures inline. 3584 \"\"\" -> 3585 from matplotlib_inline.backend_inline import configure_inline_support
04-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值