a lot of lagging for a big file inside jupyter lab - jupyter-lab

I love jupyter lab. But for a big file ( 600KB), scrolling the file has a lot of lagging. I move my mouse to scroll down or up, but I have to wait for 5-20 seconds before the page starts to move. For the same file, if I open in VSC, it is very smooth without any lagging. so it is not related to my file issue. it is something to do with jupyter lab.
I am using latest jupyter lab version.
Any suggestion I can do to remove the lagging inside jupyter lab? Thanks

Related

Pyautogui image recognition returns None no matter what I do

I have been trying to get pyautogui to locate graphically a folder on my desktop but it fails no matter what I do:
This is my code (int_auto.py)
import pyautogui
button = pyautogui.locateCenterOnScreen('/Users/cadellteng/Desktop/Test-ground/randompy/pyxell2.png')
print(button)
I literally read through every SO thread I could find on this topic and some suggested that the photo needs to be lossless, so I used the cmd+shift+4 command on Mac to achieve this. A screenshot of my desktop and the reference image I used is attached here.
Note: This photo was converted to jpg because SO only allows photos up to 2MiB to be uploaded
Other things I tried are:
1. using locateAllOnScreen
2. grayscale = True
3. uninstall pyautogui and reinstalling pyautogui
But no matter what I did, I couldn't seems to be able to get the outcome I want. If it helps, I use a double screen and my code editor (VS Code) is on the secondary screen. What you see here as my desktop is my primary screen.
When the program is running nothing is blocking the folder.
There is also a warning on my terminal which I'm not sure if it's going to be useful:
/Users/cadellteng/Desktop/Test-ground/randompy/env/lib/python3.8/site-packages/rubicon/objc/ctypes_patch.py:21:
UserWarning: rubicon.objc.ctypes_patch has only been tested with Python 3.4 through 3.7.
You are using Python 3.8.2. Most likely things will work properly, but you may experience crashes if Python's internals have changed significantly. warnings.warn(
Do let me know if you require additional information.
EDIT June 01, 2020: So I thought that maybe pyautogui was not able to detect the folder because there are multiple folders and they all look the same and was not able to detect it. So I got this image off the web and tried to search it with it opened on my desktop with nothing else blocking it. But even then it was not able to find it.
I'm not sure if I am doing something wrong here but with each try, I am becoming more convinced that this API is broken.
The size of the picture might be a problem. When I use locateOnScreen to find an element in a browser and zoom out by, for example, 10%, then it will not locate it on screen even if is almost the same.
You have a Macbook so I think its because of the pixel density of the screen and the resolution pyautogui detects. You can check by:
image = pyautogui.LocateCenterOnScreen(‘image.png’)
print(image)
If you see coordinates above 2000 its probably because of the resolution. I suggest a workaround if you want to click the image like:
pyautogui.click(image.x/2, image.y/2, clicks=1, interval=10, button=‘left’) also try cropping the images as small as possible!

jupyter lab reopen previous closed/shutdown notebook

After closing jupyter lab and re-launching jupyter lab, it always opens a notebook that was shutdown in previous session. How do I properly remove that notebook from re-opening on every launch?
jupyter lab --version #1.2.15
any notebook created in Jupyter lab gets auto saved and by default it autoloads the previous session which was last worked upon. Even your untitled notebooks gets autosaved, you can always check in the path where it is installed
[right click the kernal and there ill be a delete option or use the close button (x) right on top]

Jupyter Notebook didn't save for over a day. How can I recover lost work?

I've lost a day's work in Jupyter Notebook because it didn't autosave. As I was working, I would click on File > Save and Checkpoint to be safe. I closed the notebook when I finished working and when I tried reopening it, I see that essentially all my work is gone and it says Last Checkpoint: a day ago (autosaved) next to the filename. I now realize that I had been working for a long time on the notebook with an orange box with some kind of error message. I'm sorry that I can't remember the specific message right now, but I think it was something involving POS or POST or POSIT ...?. I saw Trusted next to the error message, so I must've thought things were OK.
I tried opening the filename-checkpoint.ipynb file within the .ipynb_checkpoints folder but it's blank. I looked up a possible solution on Recovering from a Jupyter Disaster, but it requires SQL, which I don't know. Is there any hope for recovering my work? I realize that this is probably a rookie mistake, but I'm pretty new at this.
Thanks
PS: I'm running Python3 on MacOS
Hope you've already found how to recover lost work from Jupyter notebook work. If not, try the following:
Go to Anaconda Navigator (the green circle!)
Launch a Jupyter Lab
In Jupyter Lab, open a Terminal window
Launch iPython in the terminal by typing ipython and hitting enter
Hit Up arrow
All your code are stored in history and each cell compilation that you would've done in the past shows up there.
Copy+Paste it back to a new Jupyter notebook and you are ready to go again!
If you want to copy/paste.
After running terminal and ipython, page_up yo code you want. Click right button on a mouse, then Watch the elements code. Now you can select code, copy and paste it.
If you don't have Anaconda Navigator you can do access the same data the manual way:
open a new ipython terminal
type %history -g -f history.txt
This will output the entire history of edits which are saved in history.sqlite in your IPython profile folder. You can scroll down to the bottom to find your most recent edits.
You can also just explore the history.sqlite directly, which is located in your IPython profile. The profile should be inside .ipython in your user directory (windows and linux).
Thanks to Christian Long's answer on another question for providing this info.

Jupyter notebook won't let me save itself

I have a Jupyter notebook called "Visual Magnitude.ipynb" on my Windows box. I've used this notebook for several years. It's under CM control (perforce is our CM tool). Normally I don't have it checked out, so it's marked as read-only on the file system. Sometimes I open it up (knowing it's read-only), add a few cells, look at some results, and close it out, knowing the new cells won't be saved. This is ok.
But lately I've run into a situation where I forgot to check it out of perforce first, then added/modified some cells. When I went to save it Jupyter complained it was read-only. So I checked it out (thus removing the read-only status on the file system). Jupyter still doesn't recognize this. So I quit Jupyter all together and restart it with the notebook (which is now writable). But Jupyter refuses to recognize this and still treats it as if it were locked. Almost as if it's caching the file status in some location.
I've rebooted and still have the same problem. What am I missing to convince Jupyter that this notebook is now writable?
I'm using Jupyter 4.4.0.
It turns out that there was a hidden file .~Visual Magnitude.ipynb in the same folder that was still marked read only. Once I deleted that everything was fine.

Highlight to select and Middle-button to paste in jupyter notebook?

In Jupyter Notebook, when I highlight text either from within a cell in the notebook or from outside the notebook, Middle-Button click doesn't paste anything as it is supposed to do in many other applications in linux. Is there any setting that would allow one to be able to paste with a Middle-Button click into an Ipython or Jupyter Notebook?
I'm using the notebook in firefox if that matters.
The fact that you're using Firefox definitely matters. See this issue on CodeMirror (CodeMirror is the text editor that Juypter uses): Issue #931
In that thread, it references this Firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=846674
It seems as though the issue has only recently been fixed, so it may take a little bit to trickle into CodeMirror. You may want to comment on the issue in CodeMirror to inform them that the issue has been fixed on FF and it might prompt them to investigate.
However, Jupyter doesn't automatically use the most recent version of CodeMirror so again you may have to wait a while. If this issue is truly critical then I suggest switching to another browser.

Resources