I am trying to enable ipywidgets on jupyterlab. I am have npm and jupyterlab installed. However, every time I try jupyter labextension install @jupyter-widgets/jupyterlab-manager command, I get the following PermissionError.
I haven't had much luck with just googling the error.
I am using Windows 10 and anaconda as my package manager.
Thanks for the help
(py37) C:\Users\adavoody\Documents>jupyter labextension install @jupyter-widgets/jupyterlab-manager
Node v11.11.0
> C:\Users\adavoody\AppData\Local\Continuum\anaconda3\envs\py37\npm.CMD pack @jupyter-widgets/jupyterlab-manager
npm notice
npm notice package: @jupyter-widgets/[email protected]
npm notice === Tarball Contents ===
npm notice 2.0kB package.json
npm notice 1.5kB LICENSE
npm notice 2.0kB README.md
npm notice 131B lib/index.d.ts
npm notice 410B lib/index.js
npm notice 2.5kB lib/manager.d.ts
npm notice 6.2kB lib/manager.js
npm notice 1.9kB lib/output.d.ts
npm notice 6.0kB lib/output.js
npm notice 1.1kB lib/plugin.d.ts
npm notice 3.6kB lib/plugin.js
npm notice 829B lib/renderer.d.ts
npm notice 3.0kB lib/renderer.js
npm notice 216B lib/semvercache.d.ts
npm notice 972B lib/semvercache.js
npm notice === Tarball Details ===
npm notice name: @jupyter-widgets/jupyterlab-manager
npm notice version: 0.38.1
npm notice filename: jupyter-widgets-jupyterlab-manager-0.38.1.tgz
npm notice package size: 8.5 kB
npm notice unpacked size: 32.3 kB
npm notice shasum: 1b1e17c929065bd2a93057b2378562c10c3db6c0
npm notice integrity: sha512-JutIwjs2jq6qW[...]Phr69YQ+qQZ/Q==
npm notice total files: 15
npm notice
jupyter-widgets-jupyterlab-manager-0.38.1.tgz
Errored, use --debug for full output:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\adavoody\\AppData\\Local\\Temp\\tmpgzehuvco'
Great question. I would try rebooting to get rid of that process that apparently is using that file.
Great question. I would try rebooting to get rid of that process that apparently is using that file.
I have already tried rebooting.
However, a new piece of information is that when I tried building from source, I got the same error, but now jupyter lab recognizes the extension manager and the ipywidgets are rendering but not responding to callback functions.
I have the same problem, and traced it back to a race condition with children processes created by npm. By adding a short sleep (~5ms) to python core lib TemporaryDirectory() __exit__ handler after a PermissionError, it resolved itself when self.cleanup() was called for a 2nd time.
Switching back to npm10 did not resolve this.
I tried using psutil at the jupyterlab/commands.py ProcessProcess(Process) : wait() function (latest 1.0.0a8 build) to look for children recursively to build a process group tree, but it never caught any children processes of npm using the pid started by Popen.
I did determine that parent npm.exe pack calls are the source of the problem.
I'm not certain what the best way to handle this is from the commands.py side of Jupyter? Windows doesn't seem to handle children group PID termination well.
In my digging around, I noticed python/cpython@e9b51c0ad81da1da11ae65840ac8b50a8521373c is already modifying TemporaryDirectory to prevent PermissionErrors in Windows with read only files, but this is tangently related to that. In fact, I'm unsure if it would brute force a solution here by changing the folder permissions while an orphan process has it actively locked.
I followed this suggestion and it worked for me
https://github.com/jupyterlab/jupyter-renderers/issues/127#issuecomment-505964361
I am experiencing this issue when trying to install the pyviz panel dependencies. In particular, the jupyterlab extension can't install.
>>> jupyter labextension install @pyviz/jupyterlab_pyviz
An error occured.
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\FOO\\AppData\\Local\\Temp\\3\\tmpjpbucb39'
See the log file for details: C:\Users\FOO\AppData\Local\Temp\3\jupyterlab-debug-b_usldbm.log
python 3.7.3
panel 0.6.0
Windows 10
Node.js v12.4.0.
Will this be resolved in a more formal manner besides modifying the shutil.py module?
If I understand this issue correctly, it doesn't seem to be an issue with ipywidgets, but with an interaction between TemporaryDirectory and npm in JupyterLab. Opening a ticket in JupyterLab, and linking back to this one seems an appropriate step for a more official workaround.
Possible resolution for lab, is to use this official workaround:
https://docs.python.org/3/library/shutil.html?highlight=shutil#rmtree-example
CPython bug tracked since 2016: https://bugs.python.org/issue26660
Note, this seems to have been resolved for Python 3.8, so the issue might simply be wontfix in lab?
@vidartf Thanks for the CPython bug and fix references as I knew that it is related to CPython code base and not ipython/jupyter widgets codebase. I guess perhaps it is time for me to upgrade to 3.8.
Thanks. Closing this as resolved. The solutions are to upgrade to Python 3.8+, or opening an issue on the jupyterlab repo, asking for lab to use the workaround until 3.7 is dropped from LTS (probably a reasonable request, as the code required is small).
Lab issue for those interested: https://github.com/jupyterlab/jupyterlab/issues/7025
Most helpful comment
I followed this suggestion and it worked for me
https://github.com/jupyterlab/jupyter-renderers/issues/127#issuecomment-505964361