Run Jupyter Notebook with Admin Priveleges in Linux - python

I am trying to webscrape a javascript website. In order to do this I am reviewing a chapter in this text:
https://yanfei.site/docs/dpsa/references/PyWebScrapingBook.pdf
and trying to reproduce an example which uses this script:
from selenium import webdriver
import time
driver=webdriver.Firefox(executable_path='')
driver.get("http://pythonscraping.com/pages/javascript/ajaxDemo.html")
time.sleep(3)
print(driver.find_element_by_id("content").text)
driver.close()
When I run this I get a permission denied error in the third line. I am not completely sure(correct me if I am wrong), but I think the reason is because I am on a Linux machine and I am not running Jupyter notebook as an administrator. However, I cannot figure out how to do that. If I go to the terminal and write:
sudo jupyter notebook
it says that the command is not found, even though just writing jupyter notebook is how I open the application from the command terminal. I have tried running anaconda navigator and the same thing happens. My question is whether or not the administrator issue seems like the correct answer to the above problem, and, more generally, how do I run the application as an administrator.

You maybe haven't got the geckodriver installed? I install pygeckodriver via pip and firefox-geckodriver viz apt and it now works without the "executable_path" parameter

Related

Not able to setup vscode.dev to run Python or Jupyter in browser (without downloading or installing)

I am trying to use online browser based version of visual studio code (https://vscode.dev). I installed the extension Python and Jupyter. But when I try to run any code, I get following error.
"Error loading webview: Error: Could not register service workers: NotSupportedError: Failed to register a ServiceWorker for scope".
Looking for your kind help please.
Thanks.
Fast soluton: Open the terminal and type killall code. Easy & lazy solution: Reboot your computer.
If this does not work, try reinstalling or updating vscode
In my case, this was related to a CORS configuration issue. What fixed it for me was launching the notebook from the terminal with the origin specified:
jupyter notebook --no-browser --NotebookApp.allow_origin_pat=https://.*vscode-cdn\.net
If for some reason that doesn't work, you could try the following as a last resort (bearing in mind this will allow ANY origin):
jupyter notebook --no-browser --NotebookApp.allow_origin='*'
Source:
https://github.com/microsoft/vscode-jupyter/wiki/Connecting-to-a-remote-Jupyter-server-from-vscode.dev

Jupyter Notbooks not launching

I'm running Python 3.8 (Anaconda) on Windows 10 and have previously not had any issues launching Jupyter Notebooks. Today that changed: When I tried to launch it from the Anaconda Navigator, it suggested that it launched it but didn't open anything in my default browser (Chrome), so nothing really happened. Also, not terminal prompt was launched. When I tried launching it from the command line, typing both jupyter notebook and jupyter-notebook it launches the notbook but only in the background (ie. it provides a link that I need to copy into my browser). I find this quite strange and am trying to understand what's going on. My hunch is that it's some kind of Windows related issue but I'd like to know what issue.
So my question is what can explain this behaviour? And assuming that this is related to some strange Windows issue, I'd be keen to find out what it is.
I replicated the exact steps I used to always launch it (which worked), so this shouldn't be anything to do with the setup.
Cheers!

Jupyter - Not sure if not working or broken link

I am trying to open a notebook with jupyter, by using the following command:
jupyter notebook notebook.ipynb
I use Linux and python2, I have installed jupyter inside a virtualenvironment with pip.
When I run the command above, what happens is that I get a new screen
REFRESH(1 sec): http://localhost:8889/notebooks/mylink
This page should redirect you to Jupyter Notebook. If it doesn't, click here to go to Jupyter.
However, there is no dashboard opening automatically. So, I clicked on the link, but I am unable to connect. The weird think is that I don't remember what I did yesterday, but I managed to get through very easily.
Am I doing something wrong? Or maybe there is a problem with the link?
EDIT: If I run
jupyter notebook.ipynb
I get
Error executing Jupyter command 'notebook.ipynb': [Errno 2] No such file or directory
which does not make sense, because the file notebook.ipynb is actually there.
If I type
jupyter notebook stop
I get
There are no running servers
Happened to me too. Also their troubleshooting could not resolve the issue. You may note the This Worked An Hour Ago section.
If you are using environments, try creating a new environment and install jupyter notebook from scratch there. For Anaconda it would look like this:
conda create --name jupyter_env
conda activate jupyter_env
conda install -c conda-forge jupyterlab
jupyter notebook
You may change jupyter_env to a differen name of your liking.
What I usually do is run
jupyter notebook
and it will automatically open up the browser with my current directory. I then search for my notebook that way.
I guess one of these could help you fix this one:
change url to http://127.0.0.1:8889/notebooks/mylink or http://0.0.0.0:8889/notebooks/mylink
in case proxy or any other network settings set on your browser, disable them and check twice
if none of them did work, try to enter the url this way: http://localhost:8888/tree?
And, provide logs from console might help as well.
And one more thing, just to make sure, why you're connecting via port 8889? did you tried to run jupyter by --port command option?

Jupyter notebook webpage is a blank screen

So I bought this fancy shmancy Codecademy Pro subscription to take the data science track, but it appears that it has a rather disappointing lack of documentation for part six of its course. I'm learning about Python right now, and I just downloaded the newest version of Miniconda, which included Python 3.7.2. I'm trying to open a .zip file (called Reggie's Linear Regression.zip) using the command
jupyter notebook
and it works, to some extent; it automatically launches a Chrome page, but it's just blank. I get this error in the Chrome console:
Refused to execute script from '<URL>' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
I want it to show this file: Reggie_Linear_Regression_Skeleton.ipynb. It just opens in my notes app when I click on it in file explorer.
I'm very new to Python and downloading libraries and stuff (this is actually my first time), so even just pointing me to other resources that would help me with this problem would be helpful as I don't even know how to describe the issue. Also, I'm 100% sure I've navigated to the correct folder in the Anaconda prompt.
Thanks so much
The latest version seems to be broken, try to downgrade jupyter. If you install with Anaconda the command is:
conda install -c anaconda notebook=5.7.4
Yeah, looks like the latest version is broken. There is already a pull request but it is not yet merged https://github.com/jupyter/notebook/pull/4468. That is a pretty simple fix, so you can also do it yourself for the time being https://github.com/jupyter/notebook/pull/4468/files
I was facing the same issue.
Downgrade jupyter notebook. If you face the blank page againg, after opening jupyter notebook on broswer press "ctrl+f5" to force restart the page.

How to make chrome compatible with Jupyter for Anaconda?

I am an anaconda user and Jupyter is a neat tool to run python code. However, for my macbook, I can't open it in Chrome (This page isn’t working
localhost didn’t send any data.),but it works in Safari, I have tried to reinstall chrome, but I still can't fix it. My system is Mac OS 10.11.5.
Who knows how I can fix it?
I can understand that the problem might be not specific enough, but I have been puzzled by this problem for quite a period of time.
There was a similar problem in the git page for Jupyter:
https://github.com/jupyter/notebook/issues/2438
Try going to directly to http://localhost:8888/tree
or whatever port you are using.
Download jupyter notebook from link below
Download jupyter notebook
Once you downloaded it, run it any browser it will work
Just copy paste the link with token from the terminal to chrome.
It should work after that.
The steps are :
Cd to directory u want to go to
Type jupyter notebook , a browser window opens up after this command.
If safari opens up copy paste the link from safari to chrome.
It might ask u for a token the first time. That can found in the terminal where jupyter command is typed.

Categories

Resources