Clicking does not work in Jupyterlab [OS X, chrome] - python

Bug description:
No response when clicking any buttons except files.
When I want to leave one cell to another, weird jumping back happens.
The demo below is more explanatory.
To Reproduce:
On my mac, basically after opening Jupyterlab, all clicks inside give no responses.
Expected behavior:
A normal and smooth experience like before.
Screenshots:
demo
Desktop (please complete the following information):
OS: [OSX 10.14.3]
Browser [chrome 72.0.3626.119]
JupyterLab [0.35.3]
Additional context:
Jupyterlab worked well one week ago on my OS X 10.11 El Capitan. And then I want to add a plugin (#lckr/jupyterlab_variableinspector). So I need to upgrade my node, npm and thus my OS X. After upgrading them and install the plugin, the problem happens. But I am not sure it is because of the version, because I did not use Jupyterlab in this week and may do something else to my system. I tried to disable the plugin and it did not help.

Problem solved. It was caused by a Chrome plugin with similar functions like "RightToCopy". I just deleted it and reinstalled the Chrome, then everything works well.

Related

Programmatically Execute Cell Jupyter VSCode

I am looking for a way to programmatically replicate the Run Cell Below functionality VS code.
Previously, I used Jupyter through Conda and used the following code:
import ipywidgets as widgets
from IPython.display import display,Markdown,Javascript,HTML
def run_below(ev):
Javascript('IPython.notebook.execute_cells_below()')
button = widgets.Button(description="Click to run cells below")
button.on_click(run_below)
display(button)
This code worked great, but when I tried to plop it into VSCode, the button just does nothing. I don't understand much about how the VSCode Jupyter backend works, but I'm imagining it has something do do with the IPython.notebook module not working correctly in this IDE (or perhaps the IPython.display.Javascript module?). I really have no real idea though.
Does anyone know how I could do this in VSCode's Jupyter implementation?
I have searched for hours on this topic, but have not been able to find a working solution that works. Please let me know if y'all have any ideas.
Environment Info:
Python Version: 3.9.12
VSCode Version: 1.69.0
Jupyter Extension Version: v2022.6.1001902341
It appears that the ability to access the Kernel in VS code is not possible at this time. See the following GitHub issues to see if this has changed at the time of reading:
Similar question migrated to #6918
Issue #6918 that will resolve problem once closed
Not exactly an answer to detailed question but is an answer to the title of the question "Programmatically execute cell jupyter vscode" since I landed on this page searching for how to do this. The following code supports this task - just make sure to hit save CTRL-S if you make changes to cells that are going to be run by the following function since it reads the current version of file from disk
def execute_cell(filepath,cell_number_range=[0]):
import io
from nbformat import current
with io.open(filepath) as f:
nb = current.read(f, 'json')
ip = get_ipython()
for cell_number in cell_number_range:
cell=nb.worksheets[0].cells[cell_number]
#print (cell)
if cell.cell_type == 'code' : ip.run_cell(cell.input)
also for finding name of current notebook in vscode is easy but not easy in jupyterlab
import os
globals()['__vsc_ipynb_file__'] #full name only in vscode
os.path.basename(globals()['__vsc_ipynb_file__']) #basename only in vscode . globals()['_dh'] #dir in most

Installed Python 3.10.2 and now my Pip installs are not being found

Everything in my code was working perfectly fine up until I decided I wanted to utilize match-case in Python. Find out its only a thing in 3.10+, so I quickly install it and change it to be the interpreter in command palette.
Then I try to run my code same as before, and I'm not sure what changed but my Keyboard import is giving me 'Import "keyboard" could not be resolved'. Issues. The same issue was actually present as well with the 'from nis import match' module.
I installed keyboard initially using 'pip install keyboard' when running my 3.9 version, and legit everything was fine. This all started after I installed 3.10 (which I did from Pythons website yes); and I did add to PATH, but I dont think that would have any impact on my imports in VScode.
Confused as heck right now, please look at my screenshots for clearest explanation of what I'm facing.
Import could not be resolved
.
Module Not Found Error
.
pip3.10 show keyboard
.
My interpreter list from command palette
Any and all help appreciated, I'm extremely confused and think I've tried it all now
New Python versions use new site-packages folders. You need to reinstall everything. This is why poetry, pipenv, or requirements.txt are used
I think the linter-like extension/whatever Pylance is is the problem. Why? Because as we've tried, pip install keyboard and pip install --upgrade keyboard just confirm that the requirement is satisfied and the latest version of keyboard is already installed.
What I did was change Pylance's settings. Yes, it's not an actual error (with the code), but Pylance's problem. It just didn't see enough files in the keyboard package to satisfy its hunger, or Microsoft was just too lazy to pass more checks and update it accordingly, because however it happened, when I tried changing the setting to display an "error" at "missing imports" for fun, it didn't show errors or the default "warning" but "none", because I had run the file before I changed it back to display an error (maybe Pylance observed that when the file was run, there was no ModuleNotFoundError, and so stopped showing the warning).
I better shut now, because the setting I changed/overrode by adding it in settings.json is:
"python.analysis.diagnosticSeverityOverrides": {"reportMissingImports":"none"}
which is in:
{
...,
...,
...,
"python.analysis.diagnosticSeverityOverrides": {"reportMissingImports":"none"}
}
Here is a list of keys like "reportMissingImports" whose values you can change. These are the allowed values for the keys in python.analysis.diagnosticSeverityOverrides:
error (red squiggle)
warning (yellow squiggle)
information (blue squiggle)
none (disables the rule)
You would want to change their values only if you want to change their behaviour.
You can find settings.json by its path or by going to the settings GUI and clicking on any "Edit in settings.json" link-like button. You can also make settings.json open instead of the GUI by default.
Now, you won't see any more warnings when you import modules and can code without being anxious about the stupid warning.
Wow, So as it turns out, a solution I tried previously, to no avail is now working to solve this bizarre issue.
Simply put, I once again went to Command Palette (Ctrl+Shft+P), and looked through my interpreters I had to see what could be wrong.
Decided to click on the 'recommended' option I assumed I had been running this whole time. Turns out I was using this 'third' option as shown in the screenshot (the one not highlighted ofcourse); and it's the reason my module installs were being found on my machine, but not by the interpreter; as such giving me errors and not running the module for the program.
Simple error, but thanks to those who did help.

Python Selenium execute_script jQuery Error and Discrepencies Between OSs

I'm using Selenium with Python (3.5) to programmatically explore a site. One step of this exploration includes scrolling to the bottom of a given page, and I have chosen to do so with jQuery as such where driver is the webdriver object and scrollloadtime is the set amount of time I want the scrolling to take:
driver.execute_script("$('html, body').animate({scrollTop: $(document).height() - $(window).height()}, %s);" % scrollloadtime)
This is where things get weird. When I run this code in a test environment (VM running Kali Linux), I have no issues with this -- I've never once had a problem with this line running in this environment.
However, when I attempt to run the exact same code with the exact same package versions (which I have listed below) on the exact same webpage inside a docker container running Debian Stretch, I get the following error:
Message: TypeError: $(...).animate is not a function
I'd like to figure out why this is happening rather than just a workaround. It's driving me insane!
I'm certainly no jQuery expert, but from the research I've done on the above error this normally occurs when either an old and minimized jQuery version is being used. What I can't figure out myself is how that solution then ties into Selenium or even Python itself.
Things I have tried, to no avail:
Installed jquery-related packages that exist on my test environment that did not exist within the docker image, on the docker image (i.e. all libjs-jquery* packages).
Attempted to inject jQuery into the page before running the script which triggers DDoS security. (Additionally, this shouldn't be necessary because the jQuery script worked without any injection in the test environment)
Attempted to exchange the initial $('html, body') with a defined variable (var x = document.getElementsByTagName('html')[0]; x.animate(...), though I will be the first to admit that I might not have done so correctly
Versions:
Python 3.5
Selenium (Python) 3.141.0
Geckodriver 0.24.0
Firefox ESR 68.1.0
Debian Stretch and Kali Linux
Any assistance or troubleshooting guidance would be greatly appreciated. Let me know if I can provide any additional information.

Mayavi example fails, crashes python on Ubuntu

I'm trying to run a standard Mayavi example. I just installed mayavi2 on Ubuntu (Kubuntu 12.04) and this is my first step with Mayavi. Unfortunately, this step is failing.
The examples I wish to run come from here:
http://docs.enthought.com/mayavi/mayavi/auto/examples.html
For example, this one.
The behavior I am seeing is that the plot canvas area is blank (mostly). The popup window is shown and its controls are present and working.
The only errors I am seeing are:
libGL error: failed to load driver: swrast
libGL error: Try again with LIBGL_DEBUG=verbose for more details.
Where would I add LIBGL_DEBUG=verbose?
I'm on Kubuntu 12.04 with:
Python 2.7.3
IPython 1.1.0
wxPython 2.8
vtk 5.8.0-5
setuptools, numpy, scipy - latest versions (just updated)
I am running the examples in IPython (which seems to be the recommended way). I am using this command to start the shell:
ipython --gui=wx --pylab=wx
I also tried running the examples from within an IPython notebook as so:
%run example.py
In all cases the examples fail to display the animation. The window itself is display as are the controls. But the animation canvas is mostly blank, although a flash of the images will sometimes appear.
At least once previously I saw my attempts crash Python. The message was:
The crashed program seems to use third-party or local libraries:
/usr/local/lib/python2.7/dist-packages/traits/ctraits.so
/usr/local/lib/python2.7/dist-packages/tvtk/array_ext.so
However, I am not seeing that crash now.
I found some important clues here:
https://askubuntu.com/questions/283640/libgl-error-failed-to-load-driver-i965
Like that person, I ended up reinstalling my graphics driver and that solved my problem. (The problem wasn't related to mayavi or python after all.)

Sublime Text 3 plugin Anaconda can't do multiple-line lint

I am using Sublime Text 3 (build 3047) using package control and the newest Anaconda plugin for python development. However I am facing a rather odd issue.
Using the default linter included in anaconda (not pylint), the plugin only displays the very first error it encounters.
So, if for example I am having errors in line 3, 5 and 10, only line number 3 will be highlighted. PEP8 is also currently disabled.
Is there any way to work around this problem and show all errors in a file at once?
Thank you.
There is no reason that you don't get any more errors linted in the buffer. The only thing that come to my mind is a possible incompatibility with any other ST3 plugin that you have installed as well.
You can do several things to try to figure out what can be wrong:
1) Take a look at the Sublime Text console to see if there are errors raised by Anaconda or other plugin
2) Take a look at your Anaconda JsonServer logs, you can fin them on: $HOME/Library/Caches/Jedi on Mac OS X, $HOME/.cache/jedi on GNU/Linux or %APP_DATA%\Jedi\Jedi on Windows.
You can get some support as well just joining the Anaconda mailing list at https://groups.google.com/forum/#!forum/anaconda-st3-plugin or just opening a new ticket in the project GitHub site: https://github.com/DamnWidget/anaconda/issues

Categories