zoukankan      html  css  js  c++  java
  • 关于ipywidgets插件,错误'Widget Javascript not detected. It may not be installed or enabled properly.'

    一、问题描述:

    安装ipywidgets后,我在运行下述代码时,出现了错误``

    import torch
    import torchvision
    import torchvision.transforms as transforms
    import matplotlib.pyplot as plt
    import ipywidgets as widgets
    import sys
    sys.path.append("..")
    import d2lzh_pytorch as d2l
    

    错误显示:

    Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz to C:Users木子/Datasets/FashionMNISTFashionMNIST
    aw	rain-images-idx3-ubyte.gz
    Widget Javascript not detected.  It may not be installed or enabled properly.
    A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells.
    

    错误截图:

    二、问题分析:

    可以用命令pip search widgetsnbextension检查是否能在后台找到这个插件,如果不能就需要重新安装。可以尝试下面这个解决方法:

    然而上面的运行我并没有解决,于是进行了后续步骤。我安装的版本是4.x,查看了一系列解决方案,大概指这个4.X版本在jupyter notebook中工作,会有一些不支持。安装5.0.0版本,就可以解决这个版本存在“找不到
    插件的问题”。于是我又重新安装5.0.0版本。(详看第三点)

    三、问题解决:

    1. 我首先使用命令pip install ipywidgets==5.0.0(失败,因为我已经安装了4.x版本,无法下载。)

    错误代码:

    Installing collected packages: ipywidgets
      Found existing installation: ipywidgets 6.0.0
    ERROR: Cannot uninstall 'ipywidgets'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
    

    错误截图:

    这个是anaconda的保护机制,显示:这是一个distutils的安装项目,因此,我们无法准确判断哪些文件属于它,这将导致只有部分卸载。,防止环境打乱。在卸载时,这种错误比较常见,实在想卸载,也可通过修改第三方文件夹的权限。(参考其他博文)

    2. 命令:(依旧失败)

    pip install --ignore-installed --upgrade ipywidgets==5.0.0 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
    

    这个命令--ignore-installed可以忽略已经安装的版本,安装特定版本。后面为了网速快,特地加了阿里云的镜像。
    错误代码:

    Installing collected packages: attrs, setuptools, zipp, importlib-metadata, six, pyrsistent, jsonschema, ipython-genutils, pywin32, decorator, traitlets, jupyter-core, nbformat, Send2Trash, tornado, prometheus-client, MarkupSafe, jinja2, pywinpty, terminado, pyzmq, python-dateutil, jupyter-client, pickleshare, colorama, parso, jedi, pygments, backcall, wcwidth, prompt-toolkit, ipython, ipykernel, webencodings, bleach, entrypoints, testpath, defusedxml, mistune, pandocfilters, nbconvert, notebook, widgetsnbextension, ipywidgets
    ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'd:\installsoftware\anaconda\envs\spyder_py3.5\Lib\site-packages\win32\win32api.pyd'
    Consider using the `--user` option or check the permissions.
    

    错误截图:

    大意是拒绝访问,由于环境错误无法安装包。同时给出了解决办法加上--user

    3. 安装命令(ipywidgets 5.0.0版本安装成功)

    pip install --ignore-installed --upgrade ipywidgets==5.0.0 --user -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
    

    截图:

    这里面有很多警告,但是还好啦,终于安装成功了。到此,这个插件找寻不到的问题得到解决。

    GitHub讨论区参考:https://github.com/jupyter/notebook/issues/1386

  • 相关阅读:
    shell-条件测试
    51Nod 1279 扔盘子 (思维+模拟)
    51Nod 1042 数字0-9的数量(数位DP)
    Codeforces 1138B Circus (构造方程+暴力)
    51nod 1133 不重叠的线段 (贪心,序列上的区间问题)
    51nod 1091 线段的重叠(贪心)
    EOJ Monthly 2019.2 E 中位数 (二分+中位数+dag上dp)
    牛客练习赛39 C 流星雨 (概率dp)
    牛客练习赛39 B 选点(dfs序+LIS)
    Educational Codeforces Round 57
  • 原文地址:https://www.cnblogs.com/somedayLi/p/12356332.html
Copyright © 2011-2022 走看看