How to change Jupyter launch from file to URL? - python-3.x

I installed Python 3.7 from Windows Store, it runs perfectly. I successfully installed Jupyter and other packages with pip from cmd.
The thing is when I run Jupyter (python -m notebook) it says
and automaticaly opens the browser with an ERR_FILE_NOT_FOUND page. Opening the notebook by copy-pasting the URLs works just as expected, so how can I tell Jupyter to run by default the URL instead of the file?

At my end, the file does not open either due to security settings of Chromium (ERR_ACCESS_DENIED).
There's a config parameter which controls how the browser gets access to jupyter: NotebookApp.use_redirect_fileBool (cf. jupyter docs).
In order to change this, create a config by jupyter notebook --generate-config and edit the config file: uncomment and replace the value of line #c.NotebookApp.use_redirect_file = True by c.NotebookApp.use_redirect_file = False. On next start of jupyter, the browser is started using the http URL instead of the file.
HTH

The solution above works (UBUNDU). You just have to bare in mind a few thinks:
1st: If you use jupyter notebook you need to craete this file jupyter notebook --generate-config and look for the line c.NotebookApp.use_redirect_file = True .
If you use jupyter-lab (as I do) you need to use this command jupyter-lab --generate-config . Also, in jupyter-lab you need to find this line c.ServerApp.use_redirect_file = True . In both cases this True needs to become False .
PS. I wanted to add it as a comment but I was not able to do so due to reputation or something.
2nd: It is given in the previous answer but its easy to be missed: you need to uncomment the line (remove the "#" at the start of the line)

Related

Problem Loading Jupyter Notebook in Windows 10 Pro

I am new in Anaconda (Jupyter Notebbok) and training python. After I installed Anconda when I open Jupyter notebook, the program won't be loaded.
First I run 'jupyter notebook' from the 'command prompt':
Second, when InterneTExplorer loaded and then I click the New>Python3
Finally I expected to have 'jupyter notebook' to write python codes, but I see below picture:
Desired Page:
Can you help me to find the reason for the problem?
In the following link I have attached a video from my Desktop view.
https://www.youtube.com/watch?v=lDvYwHlvghI
Did you try to open the file from the terminal? Create an empty file. In terminal, go to that empty file directory and open that empty file from terminal in Jupyter notebook. Then try to create new .ipynb inside of that file. Just another way to test if it's browser issue or Anaconda download issue.
Command for terminal-
~cd file directory
~jupyter notebook
It will automatically open the Jupyter in your web browser from your terminal.
I copied the 'localhost' link from command prompt in the Firefox browser and solved the problem.

JupyterLab configuration file - editing jupyter_notebook_config.py has no effect

I'm using JupyterLab version 1.2.3
I have generated a ~/.jupyter/jupyter_notebook_config.py file by running jupyter-lab --generate-config.
At the bottom of the file, I have added the line c.InteractiveShell.ast_node_interactivity = "all".
However, when I run jupyter lab, the notebook still behaves as if the default value for InteractiveShell.ast_node_interactivity were set.
Is any other step required to make the configuration file active? Or how can I "debug" to better understand what the problem is?
You must generate a config file in IPython with the command:
$ ipython profile create
the created file would be ipython_kernel_config.py
On this file, you must make the changes indicated

JupyterLab installation with pip3

I installed JupyterLab with
pip3 install jupyterlab --user
Yet, when trying I try to launch it (jupyter lab), I get the following error:
Error executing Jupyter command 'lab': [Errno 2] No such file or directory
The JupyterLab installation guide on github says that: "If installing using pip install --user, you must add the user-level bin directory to your PATH environment variable in order to launch jupyter lab"
But I don't what that means, I greatly appreciate any help. I am using Ubuntu 18.04
As said by the guide itself you need to add the user-level bin directory to your PATH environment variable, in order to do so you need at first spot which is the bin folder where Jupyter lab has been installed, and after that you can add that path with a simple command:
export PATH=$PATH:/path/to/your/jupyterlab/bin/directory
and it's done. You can check if you added it by running this other command:
echo $PATH
And you should see the content of PATH variable.
This method though will just add that variable for the current shell, meaning that when you close the terminal you lose the change in the variable. In order to make it permanent you need to edit another file which is ~/.bashrc.
One thing though, it's really important that you just add this line to the file:
PATH=$PATH:/path/to/your/jupyterlab/bin/directory
without changing all the rest of the file if you don't know what you are doing.
To give you a recap on what to do to make it permanent open a new shell and type:
gedit ~/.bashrc
This will open the file where you need to add the "export PATH...etc" command right at the end of the file in a new line. Then save the changes and reboot, from now on you should be able to open Jupyter lab directly from a shell with the command:
Jupyter lab

launch jupyter notebook in specified browser on cmd line

I'm working on a computer that belongs to my company. I don't have admin privileges, in case that's relevant.
My default browser in Windows 10 is set to InternetExplorer. This is mandated by my company. (Edge or Chrome not allowed as default browser) Although I do have Edge and Firefox installed.
I know that I can change the default browser for jupyter notebook sessions by editing the Jupyter config file. But I don't want to change the default in Jupyter.
Instead, I would like to invoke "jupyter notebook" on the command line (Anaconda prompt) while specifying which browser I want it to pick up.
something like:
jupyter notebook --useBrowser edge
or similar. Is this possible?
Try this:
jupyter notebook --browser="C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe %s --new-window"
It is supposed to work like this too: jupyter notebook --browser="firefox" but doesn't in practice for me, because the python webbrowser library (which is used here) is only aware of the default browser. This needs to be manually registered.
You can check this on your system, by running a python prompt and checking:
import webbrowser
list(webbrowser._browsers)
Out: ['windows-default', 'c:\\program files\\internet explorer\\iexplore.exe']
Noticed that if I open Firefox, use the cli command from Kai Aeberli above, as...
jupyter notebook --browser="C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe %s --new-window"
and copy and paste one of the URLs from the cli output into the Firefox (non-default browser) address bar, Jupyter Notebook opens in Firefox!
Thanks for this solution! :))

Pycharm tensorflow ImportError but works fine with Terminal

I made a virtualenv with tensorflow installed and I changed Python interpreter set to the location where the virtualenv is located at. When I ran the program, it gives the error:
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
I have the following lines written in my .bashrc file
export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
export PATH=${CUDA_HOME}/bin:${PATH}
Also, I found the libcudnn.so.5 file in the following path:
/usr/local/cuda-8.0/lib64
I encountered this error before I opened PyCharm and I did manage to install the correct cudnn version. The problem is, I can use
$ source [virtualenv_path]
to active the virtualenv and run python in terminal and everything works fine, no errors shown. The program also runs without error in Pycharm's terminal but it just gives me the above error whenever I click the run button. Could there still be something wrong with the environment variable? How do I fix it?
Unfortunately in pycharm you have to set CUDA_HOME and LD_LIBRARY_PATH inside the IDE. To do that go to the Run menu->edit configurations then choose your project. Then you click on the Environment Variables and add an entry for CUDA_HOME and LD_LIBRARY_PATH. When you have done that you can run directly from inside pycharm. I would also recommend setting the defaults to have these paths as well, so you don't have to do this for every project. Also it wouldn't hurt to make sure you have the interpreter from source [virtualenv_path] set while you are on this setting page. Let me know if you have trouble finding where to do this.
I've read this other Stackoverflow post: Pycharm environment different than command line, and it seems that the problem is that openning PyCharm in the normal way won't preserve the bash environment. The solution is to open PyCharm from the command line and everything works now. All you need to do is to open PyCharm using charm and everything works fine now.
I have searched a lot, but I didn't find the right solution for this question anywhere. I found the solution with my friends and I would like to share with you also.
If your Tensorflow works in terminal properly but doesn't work in Pycharm you have two solutions:
1- Open Pycharm from Terminal. For me:
pycharm-community
2- If you are using Unity, you need to edit .profile, because Pycharm doesn't preserve .bashrc: So, open a terminal and type:
gedit .profile
Then, add the following codes at the end of the opened file:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Save and exit. Now, you can work with Tensorflow in Pycharm without the necessity of opening the Pycharm form terminal.

Resources