Using:
/opt/anaconda3/bin/jupyter kernelspec list
I get:
python3 /opt/anaconda3/lib/python3.5/site-packages/ipykernel/resources
ir /opt/anaconda3/share/jupyter/kernels/ir
apache_toree_pyspark /usr/local/share/jupyter/kernels/apache_toree_pyspark
apache_toree_sql /usr/local/share/jupyter/kernels/apache_toree_sql
sparktest_scala /usr/local/share/jupyter/kernels/sparktest_scala
But when using:
conda info -e
I get:
base * /opt/anaconda3
py35-Spark /opt/anaconda3/envs/py35-Spark
In my notebook I only see the Kernels (python3, ir, Aapache...) I do not see the new environments I set up. Why is this?
I ended up doing:
source activate py35-Spark
Then ran:
jupyter notebook
This will run a new Jupiter notebook instance, so when I go to the browser and open the notebook it uses my conda environment that I set up. I believe there is a way to use ipython kernel instead.
Related
I've been using Jupyter within VSCode with no problems for a couple weeks, but since this morning it has been unable to start a kernel to run my code.
Typically, I can just open any .ipynb file in VSCode and immediately run it with no problems. That's giving me the message:
Failed to start the Kernel.
Jupyter server crashed. Unable to connect.
Error code from Jupyter: 1
usage: jupyter.py [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
[--paths] [--json] [--debug]
[subcommand]
Jupyter: Interactive Computing
positional arguments:
subcommand the subcommand to launch
options:
-h, --help show this help message and exit
--version show the versions of core jupyter packages and exit
--config-dir show Jupyter config dir
--data-dir show Jupyter data dir
--runtime-dir show Jupyter runtime dir
--paths show all Jupyter paths. Add --json for machine-readable
format.
--json output paths as machine-readable json
--debug output debug information about paths
Available subcommands: dejavu lab labextension labhub nbconvert
Jupyter command `jupyter-notebook` not found.
View Jupyter log for further details.
I can, however, open a local host in a browser using:
python3 -m notebook
in my terminal.
Any help is greatly appreciated.
I had the same problem. Seems there was an issue in a previous release of the Jupyter extension for VScode (see : [1])
I resolved as suggested in [1] :
uninstall jupyter from your global environment
set up a virtual environment
install jupyter in the new virtual env
select the virtual env as kernel used in VScode
run some cells (should work)
In case you want to use jupyter in your global environment :
remove the virtual environment
reinstall jupyter in your global env
select the correct global env interpreter in VScode
[1] https://github.com/microsoft/vscode-jupyter/issues/12714
I have multiple conda environments on my PC created with Anaconda and I have installed jupyterlab in two of them. I used one environment for R programming and the other for Tensorflow with Python. I have noticed that whenever I open jupyter lab in either of the environments, it always starts off where I left it. That is, the last open notebooks are opened on start. Of course, this doesn't bother me too much, but it makes me think each jupyter lab installation isn't contained within its own environment.
For example, I have two environments. Say they're called env_R and env_Python_TF. I have installed jupyter lab in both environments.
I open Anaconda Powershell prompt and launch each environment using the following commands:
(base) PS $ conda activate env_R
(env_R)PS $ jupyter lab
Say I work on jupyter lab and once I'm done, I close the browser windows and then shut down the server using CTRL+C in Anaconda Powershell prompt. Now if I open up my second environment using:
(base) PS $ conda activate env_Python_TF
(env_Python_TF)PS $ jupyter lab
Now I see the same notebooks I used with env_R opened up when jupyter lab opens in my browser.
Aren't each jupyter lab installation contained within its own conda environments? If not, have I possibly made a mistake in my configuration?
it should be within its own conda environment but Default root folder /location will remain same for jupyter notebook. You will need to change it using config file.
Here is link
I'm currently running Jupyter Notebook (Windows 7) within a Conda environment using Python 3.6.4 and my current version of Jupyter Notebook is 5.6.0. I came across the following article: Using Git Bash in Jupyter Notebook on Windows , that explains how to change the default shell within Jupyter Notebook to Bash by changing the config "C.NotebookApp.terminado_settings = {'shell_command': ['C:\Program Files\Git\bin\bash.exe']}. I've tried multiple different options for the path to bash, including just the name 'bash', with no success.
Python and Jupyter version:
Jupyter Notebook: Not changed, still using Powershell
I've read up on the Jupyter Notebook: Read the Docs , and made the changes to the jupyter_notebook_config.py found under C:\Users\UserName\.jupyter directory, without any success.
An alternative solution to your problem is to use the Windows Subsystem for Linux (WSL).
I am under Windows 10, conda 4.5.11 and Jupyter lab 0.35.3. I have also activated the Windows subsystem for Linux (WSL).
Using !wsl you can call the WSL or with %%bash for cell magics.
Inside Jupyter Lab I have:
is the %%bash cell magic referring to the WSL? According to my tests yes, I can access the same programs and I am taken to the WSL when I run bash.exe from the Conda prompt. There is an integration of the PowerShell prompt to WSL (https://learn.microsoft.com/en-us/windows/wsl/interop). The same seems to work with the conda prompt.
Here are three options:
If one opens Jupyter notebook via GitBash with jupyter notebook then %%bash magics should work
If one wishes to always be able to run bash within a Jupyter Notebook opened via Anaconda Prompt (similarly using jupyter notebook):
Edit the Jupyter Notebook config file:
Location can be found via Anaconda Prompt with jupyter --config-dir
Open the jupyter_notebook_config.py file in this directory using notepad or an IDE
Modify and save with the line of code: c.NotebookApp.terminado_settings = {} pointed instead to your bash executible (e.g.): c.NotebookApp.terminado_settings = { 'shell_command': ['C:\Program Files\Git\bin\bash.exe'] }
Edit your system environment variables:
Windows Search (with admin rights) > "Edit the System Environment Variables" > Environment Variables > Highlight "path" > Edit > Add a new line with C:\Program Files\Git\bin > OK out of all windows
Set an environment variable in Jupyter Notebook
Is it possible to start an ipython shell(in terminal) within a conda or virtualenv ?
The ipython shell should belongs to the respective environment.
I know a way to start jupyter notebook within the env, by creating a kernelspecs for the virtual env and then choosing the env kernel within the jupyter notebook.
here is the link : http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs
But this only setup the jupyter notebook for the current environment. Is there a to do the same for ipython shell
The answer given by Grisha Levit almost solved the problem. So, i am writing the complete details of the answer, how to setup a ipython console within a specific environment.
1.) Activate the virtual env:
source activate <environment-name>
2.) From within the virtual env:
jupyter kernelspec install-self --user
3.) This will create a kernelspec for your virtual env and tell you where it is:
Installed kernelspec pythonX in home/username/.local/share/jupyter/kernels/pythonX
Where pythonX is the version of the python in the virtualenv.
4.) Copy the new kernelspec somewhere useful. Choose a kernel_name for your new kernel that is not python2 or python3 or one you've used before and then:
mkdir -p ~/.ipython/kernels
mv ~/.local/share/jupyter/kernels/pythonX ~/.ipython/kernels/<kernel_name>
5.) If you want to change the name of the kernel that IPython shows you, you need to edit ~/.ipython/kernels//kernel.json and change the JSON key called display_name to be a name that you like.
6.) Running jupter/ipython console within the virtualenv.
jupyter console --kernel <kernel-name>
7.) This will start the jupyter console/shell for the current virtualenv and you can also see kernel in the IPython notebook menu: Kernel -> Change kernel and be able so switch to it (you may need to refresh the page before it appears in the list). IPython will remember which kernel to use for that notebook from then on.
I know a way to start jupyter notebook within the env, by creating a kernelspecs for the virtual env and then choosing the env kernel within the jupyter notebook.
You just need to do the same thing, but using console instead of notebook.
For example:
ipython console --kernel python2
I'm trying to use the bash kernel in iPython/Jupyter notebook, but I need sudo access within the notebook itself.
I've tried $ sudo jupyter notebook to run the notebook as root, but that only returns:
$ jupyter: 'notebook' is not a Jupyter command
So, I'm left with running $ jupyter notebook (unless there's a way to run Jupyter notebook as root).
I also can't do su root in the notebook itself because that requires an input and the notebook won't let me give an input.
Finally, there is allegedly an --allow-root option for Jupyter notebook:
http://jupyter-notebook.readthedocs.io/en/latest/config.html
However, it looks like --allow_root is no longer an option. (I've tried modifying the config file by adding NotebookApp.allow_root=True, but that doesn't work.)
Any ideas guys? Maybe I'm doing something wrong?
Just login as root, then do the following command to start the notebook :
jupyter notebook --allow-root
The solution as described here. Is to use
sudo -E env "PATH=$PATH" jupyter notebook
Basically the binary to call jupyter notebook is in the user's PATH variable, but not for root.
Best regards.
Add c.NotebookApp.allow_root=True from the root configuration files. That you don't need ask to allow-rootevery time then you start the notebook.
Edit:
Before edit the configuration file you need to run jupyter notebook --generate-config as root to make the file.
I am running the neopixel library from a jupyter notebook.
The only thing that worked for me was first running the "sudo su" command to move into the root environment and then run "jupyter notebook" (--allow-root alone didn't work for me).
You should try running the command sudo jupyter notebook --allow-root , I'm not sure why but this works. On the server it'll ask you for a password, if you have set up a password for it just type it in the box that will be shown, otherwise, type jupyter notebook password to set up a new password
Generate config
root#user# jupyter notebook --generate-config
root/.jupyter/jupyter_notebook_config.py
root#user# cd .jupyter/
root#user:/.jupyter/# gedit jupyter_notebook_config.py
Add line in jupyter_notebook_config.py
c.NotebookApp.allow_root=True
When I need to execute command as root in my notebook, I use the -A flag, that allows to access an helper program used to read the user's password when no terminal is available.
You need to modify the sudo.conf file before to declare the helper program. On a Debian Buster, I personnaly added:
Path askpass: /usr/libexec/seahorse/ssh-askpass
See the main page of sudo.conf for more information.
In case anyone is still looking for an answer, this is what worked for me:
sudo ~/.local/bin/jupyter-notebook --allow-root
Switching user using su didn't work because I didn't have jupyter installed on root. Using just --allow-root by itself also didn't work for me. This allows you to run sudo with jupyter notebook without running into the issue of "notebook" not being a valid command. Because I am using a linux terminal, jupyter-notebook is installed at ~/.local/bin/jupyter-notebook. See After installing with pip, "jupyter: command not found" for more information about where jupyter may be installed.