jupyter notebook 报错 ModuleNotFoundError: No module named ‘decorator‘等缺失包的问题

在ubuntu下,安装并运行jupyter notebook,

pip install jupyter notebook

运行(pose) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/pose/src/singleshotpose$ jupyter notebook结果:

No module named 'decorator'

(pose) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/pose/src/singleshotpose$ jupyter notebook
Traceback (most recent call last):
  File "/home/smile/.local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/__init__.py", line 27, in <module>
    from .nbextensions import install_nbextension
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/nbextensions.py", line 23, in <module>
    from .config_manager import BaseJSONConfigManager
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/config_manager.py", line 13, in <module>
    from traitlets.config import LoggingConfigurable
  File "/home/smile/.local/lib/python3.6/site-packages/traitlets/config/__init__.py", line 6, in <module>
    from .application import *
  File "/home/smile/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 17, in <module>
    from decorator import decorator
ModuleNotFoundError: No module named 'decorator'

这时候你就需要在终端下:

$ pip install decorator

然后发现$ jupyter notebook,还是报ModuleNotFoundError: No module named 'decorator'

(pose) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/pose/src/singleshotpose$ jupyter notebook
Traceback (most recent call last):
  File "/home/smile/.local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/__init__.py", line 27, in <module>
    from .nbextensions import install_nbextension
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/nbextensions.py", line 23, in <module>
    from .config_manager import BaseJSONConfigManager
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/config_manager.py", line 13, in <module>
    from traitlets.config import LoggingConfigurable
  File "/home/smile/.local/lib/python3.6/site-packages/traitlets/config/__init__.py", line 6, in <module>
    from .application import *
  File "/home/smile/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 17, in <module>
    from decorator import decorator
ModuleNotFoundError: No module named 'decorator'

这里的意思是说,在/home/smile/.local/lib/python3.6/site-packages目录下没找到decorator

再次安装:pip install decorator

(pose) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/pose/src/singleshotpose$ pip install decorator
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Requirement already satisfied: decorator in /home/smile/miniconda3/envs/pose/lib/python2.7/site-packages (4.4.2)

这里提示,decorator已经安装在:/home/smile/miniconda3/envs/pose/lib/python2.7/site-packages

所以,为了运行jupyter notebook,我们需要把/home/smile/miniconda3/envs/pose/lib/python2.7/site-packages下的decorator ,复制到/home/smile/.local/lib/python3.6/site-packages里面,才可以满足jupyter notebook运行的时候有decorator。

解决办法1:直接命令行复制过去:$ cp /home/smile/miniconda3/envs/pose/lib/python2.7/site-packages/decorator.py /home/smile/.local/lib/python3.6/site-packages

解决办法2:手动复制
/home/smile/miniconda3/envs/pose/lib/python2.7/site-packages下的decorator ,复制到/home/smile/.local/lib/python3.6/site-packages里面
在这里插入图片描述

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大家好我是科林

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值