How to add SageMath 9.4 kernel in Jupyter notebook - jupyter-notebook

I have installed SageMath 9.4, but I could not lunch it in my terminal. When I type sage it said zsh: command not found: sage then I tried
alias sage='/Applications/SageMath-9-4.app'
and type sage again it said
zsh: permission denied: /Applications/SageMath-9-4.app
next I tried to add permission on that SageMath file. I cd to Applications file and type
chmod +x ./SageMath-9-4.app
Nothing happened.
I tried these to add sage in my Jupyter notebook directly
sudo jupyter kernelspec install /Applications/SageMath-9-4.app
jupyter kernelspec install --user /Applications/SageMath-9-4.app
They didn't work.
by the way:
jupyter kernelspec list
Available kernels:
python3 /Applications/anaconda3/share/jupyter/kernels/python3
I googled these operations, but they didn't work on me. what should I do?
I want to lunch Sage in terminal when I type sage and I want to select kernel whenever I use Jupyter notebook.
The only way I can lunch SageMath is double click the App icon, and there will be a pop-out window

Here is how I got it on MacOS with SageMath 9.5 mac app install from homebrew.
(base) ➜ ~ sage -sh -c 'ls -d $SAGE_VENV/share/jupyter/kernels/python3'
/private/var/tmp/sage-9.5-current/local/var/lib/sage/venv-python3.9.9/share/jupyter/kernels/python3
(base) ➜ ~ jupyter kernelspec install --user $(sage -sh -c 'ls -d $SAGE_VENV/share/jupyter/kernels/python3')
[InstallKernelSpec] Installed kernelspec python3 in /Users/XXXXXX/Library/Jupyter/kernels/python3
(base) ➜ ~ jupyter lab

Related

Installed jupyter notebook without anaconda have error like "zsh: command not found: jupyter"

I installed jupyter notebook without anaconda.
(Maybe I think that I installed this with pip3 command.)
In terminal, I can't execute jupyter notebook with this command
jupyter notebook
but another command can execute notebook
python3 -m notebook
I added path in .zshrc file. but nothing changed.
Jupyter path
pip3 show jupyter | grep Location
Location: /Users/myName/Library/Python/3.9/lib/python/site-packages
In my zshrc file
export PATH=/Users/myName/Library/Python/3.9/lib/python/site-packages:$PATH
How can I use the command "jupyter notebook" in terminal?

How to use conda from Jupyter Lab terminal?

Question in the title. What I've tried: Installing nb_conda and nb_conda_kernels. This did allow me to choose the environment my kernel runs in. However, I am unable to use conda from the terminal inside the Jupyter Lab notebook.
Before launching Jupyter Lab:
(base)
wesle#DESKTOP-VV4V3ND MINGW64 ~/Jupyter Notebooks/jn-anomaly-detect (master)
$ conda activate general-ml
(general-ml)
wesle#DESKTOP-VV4V3ND MINGW64 ~/Jupyter Notebooks/jn-anomaly-detect (master)
$ jupyter lab
From Jupyter Lab terminal:
Change the kernel to run in the general-ml conda environment, then open up a notebook terminal:
wesle#DESKTOP-VV4V3ND MINGW64 ~/Jupyter Notebooks/jn-anomaly-detect (master)
$ conda info -e
bash: conda: command not found
as if it doesn't exist at all. Is there a known solution to this?
Edit:
I noticed that packages installed from Anaconda Navigator GUI are reflected live in Jupyter Notebook. This is an undesirable workaround as it is not efficient to open a new program, navigate through the gui, search for a package then install. All of this could be done from the terminal in 3 seconds.

Can't run jupyter notebook after installation

[when i run jupyter notebook i got this error again after all commands ][3]
enter image description here
Try this, it will reinstall everything from pypi.
pip3 install --upgrade --force-reinstall --no-cache-dir jupyter
Then Try to use this command to run you notebook as your terminal also suggested.
jupyter notebook

C++14 no visible after installing xeus-cling in Jupyter (Ubuntu 18.04 - Anaconda)

I followed the installation of the xeus-cling (created an env, activated,installed xeus-cling there) and when I want to select the C++14 kernel in a jupyter notebook it only appears Python3. What am I doing wrong?
I had the same problem. Its because jupyter-notebook is not installed in your environment. The jupyter server which is starting is the global one hence you don't see the c++14 option. The solution is:
Create a new directory and git clone the repository.
Run the conda env create -f environmental.yml command in cmd.
Run the conda activate xeus-cling command.
Run the jupyter notebook command.
You should now be able to see the c++14 and c++17 options. Step 2 created the xeus-cling environment and installs all the correct package versions including the correct jupyter notebook version.
Install notebook in your environment.
conda install xeus-cling notebook -c QuantStack -c conda-forge
You need register new kernels in jupyter:
jupyter kernelspec install PREFIX/share/jupyter/xcpp11 --sys-prefix
jupyter kernelspec install PREFIX/share/jupyter/xcpp14 --sys-prefix
jupyter kernelspec install PREFIX/share/jupyter/xcpp17 --sys-prefix

Jupyter kernel uses different Python version than Conda environment

I am not able to link Jupyter kernels to their parent Conda environments. After creating a new kernel linked to Conda environment, I'm getting a different version of Python and its dependencies inside Jupyter lab.
Here are the steps I followed:
Created a conda environment using:
conda create -n nlp python=3.6
conda activate nlp
(nlp) ➜ ~ python --version
Python 3.6.9 :: Anaconda, Inc.
(nlp) ➜ ~ which python
/anaconda3/envs/nlp/bin/python
Inside the environment I created a Jupyter kernel with:
(nlp) ➜ ~ python -m ipykernel install --user --name=nlp
Installed kernelspec nlp in /Users//Library/Jupyter/kernels/nlp
Investigating the created json file for the kernel:
(nlp) ➜ ~ cat /Users/<username>/Library/Jupyter/kernels/nlp/kernel.json
{
"argv": [
"/anaconda3/envs/nlp/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "nlp",
"language": "python"
}%
It seems to be pointing to the environment version of Python
But when I start Jupyter Lab and select the nlp kernel, I get a different version of Python and some dependencies are missing
!python --version
Python 3.5.6 :: Anaconda, Inc.
!which python
/anaconda3/bin/python
Could you please try the following steps:
conda activate nlp
conda install ipykernel
ipython kernel install --name nlp --user
After these steps please try changing the kernel again in jupyter lab to "nlp".
Thanks.
this behavior is actually normal in Jupyter lab.
If you run
import sys
print(sys.version)
!python --version
in a notebook, the print statement will give you the Python version of the conda env, while the second will give you the Python version of your base env.
The easiest workaround for this is to simply pip install jupyterlab in your conda env and then run jupyter lab in your conda env. Then, there will not be a mismatch in Python versions between the new "base" env and the conda env which will help clear up any DLL problems.
It's probably not best practice, but you do what you gotta do when working with legacy code, ig.
Can you try this :
# in base env
conda install nb_conda_kernels
conda activate nlp
conda install ipykernel
conda install ipywidgets
# install kernelspec
python -m ipykernel install --user --name nlp --display-name "nlp env"
When you run jupyter notebook, you will see 2 nlp kernels. Use the one with "Python [conda:env:nlp]"

Resources