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 
    from notebook.notebookapp import main
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/__init__.py", line 27, in 
    from .nbextensions import install_nbextension
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/nbextensions.py", line 23, in 
    from .config_manager import BaseJSONConfigManager
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/config_manager.py", line 13, in 
    from traitlets.config import LoggingConfigurable
  File "/home/smile/.local/lib/python3.6/site-packages/traitlets/config/__init__.py", line 6, in 
    from .application import *
  File "/home/smile/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 17, in 
    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 
    from notebook.notebookapp import main
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/__init__.py", line 27, in 
    from .nbextensions import install_nbextension
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/nbextensions.py", line 23, in 
    from .config_manager import BaseJSONConfigManager
  File "/home/smile/.local/lib/python3.6/site-packages/notebook/config_manager.py", line 13, in 
    from traitlets.config import LoggingConfigurable
  File "/home/smile/.local/lib/python3.6/site-packages/traitlets/config/__init__.py", line 6, in 
    from .application import *
  File "/home/smile/.local/lib/python3.6/site-packages/traitlets/config/application.py", line 17, in 
    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里面
jupyter notebook 报错 ModuleNotFoundError: No module named ‘decorator‘等缺失包的问题_第1张图片

你可能感兴趣的:(ubuntu,linux,bug)