I do not have Anaconda, but installed jupyter notebook through pip and python 3.6 (which I downloaded via Visual Studio 2022). I used the command py -m pip install jupyter notebook which worked fine. I now have a windows shortcut which opens the notebook ("C:\Windows\system32\cmd.exe" /k start <link> & py -m jupyter notebook where < link > is the link to the notebook.) I used the command py -m pip install jupyterthemes to successfully install jupyter themes.
The problem is: How do I change the theme from windows cmd? I have tried a couple of different approches. I used jt -l or some version of it to see if it would work. Here are the results:
py -m jt -l Result: C:\Users\<User>\AppData\Local\Programs\Python\Python36-32\python.exe: No module named jt
py -m !jt -l Result: C:\<...>: No module named !jt
py -m jupyter themes Result: <...> Jupyter command 'jupyter themes' not found
py -m jupyterthemes -l Result: C:\...\python.exe: No module named jupyterthemes.__main__; 'jupyterthemes' is a package and cannot be directly executed
py jt -l Result: C:\<...>: can't open file 'jt': [Errono 2] no such file or dictionary
py -m notebook jt -l Result: ... Bad config encountered during initialization Unrecognized flag: '-l'
What am I doing wrong here? Maybe I should use something different than -m (but I don't know what)? I have tried to search for an answer, but can't seem to find one form windows cmd.
What I want to change the theme to is jt -t oceans16 -T -N -kl (oceans16 theme with toolbar, filename, logo and kernel).
Related
I want to be able to run both Python 3.8 (currrent version) and Python 3.7 in my Jupyter Notebook. I understand creating different IPython kernels from virtual environments is the way.
So I downloaded Python 3.7 and locally installed it in my home directory. Used this python binary file to create a virtual environment by
> virtualenv -p ~/Python3.7/bin/python3 py37
> source py37/bin/activate
This works perfectly and gives 'Python 3.7' correctly on checking with python --version and sys.version.
Then for creating IPython kernel,
(py37) > ipython kernel install --user --name py37 --display-name "Python 3.7"
(py37) > jupyter notebook
This also runs without error and the kernel can be confirmed to be added in the Notebook. However it does not run Python 3.7 like the virtual environment, but Python 3.8 like the default kernel. (confirmed with sys.version)
I checked ~/.local/share/jupyter/kernels/py37/kernel.json and saw its contents as
{
"argv": [
"/usr/bin/python3",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3.7",
"language": "python"
So naturally I tried editing the /usr/bin/python3 to point to my Python 3.7 binary file path that is ~/Python3.7/bin/python3, but then even the kernel doesn't work properly in the notebook.
What can I possibly do?
NB: I use Arch Linux, so I installed jupyter, virtualenv, ... through pacman not pip as its recommended in Arch.
Found it myself, the hard way. Let me share anyway, in case this helps anyone.
I guess, the problem was that, jupyter notebook installed through pacman searches for python binary files in the PATH variable and not in the path specified by the virtual environment. Since I installed Python 3.7 locally in my home directory, Jupyter can't find it and it might have defaulted to the default python version.
So the possible solutions are:
Install Jupyter Notebook through pip (instead of pacman) within the virtual environment set on Python 3.7 (This is not at all recommended for Arch Linux users, as installing packages through pip can probably cause issues in future)
> wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
> tar -xvf Python-3.7.4.tgz
> cd Python-3.5.1/
> ./configure --prefix=$HOME/Python37
> make
> make install
> virtualenv -p ~/Python3.7/bin/python3 py37
> source py37/bin/activate
(py37) > pip install notebook
(py37) > python -m notebook
Install Python 3.7 within default directory (instead of specifying somewhere else). Create a new IPython kernel using the suitable virtual environment and use jupyter-notebook installed through pacman. (Recommended for Arch Linux users)
Note 1: > python points to the updated global Python 3.8 version and > python3 or > python3.7 points to newly installed Python 3.7
Note 2: Once the required kernel is created, you might even be able to use that python version outside the virtual environment.
> wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
> tar -xvf Python-3.7.4.tgz
> cd Python-3.5.1/
> ./configure
> make
> sudo make install
> virtualenv -p $(which python3.7) py37
> source py37/bin/activate
(py37) > ipython kernel install --user --name py37 --display-name "Python 3.7"
(py37) > jupyter notebook
Add the path of the directory where you have locally installed the new Python version to the $PATH variable, create an IPython kernel and run Jupyter Notebook within suitable virtual environment. (Haven't yet tried this one personally. Just felt that this should work. So no guarantee. Also I don't think this is a good solution)
> wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
> tar -xvf Python-3.7.4.tgz
> cd Python-3.5.1/
> ./configure --prefix=$HOME/Python37
> make
> make install
> export PATH="$HOME/Python37/bin:$PATH"
> virtualenv -p py37
> source py37/bin/activate
(py37) > ipython kernel install --user --name py37 --display-name "Python 3.7"
(py37) > jupyter notebook
Another approach is to just run the notebook application directly using the version of Python you require - provided it's installed for that version of Python (e.g. on a Mac with brew installed version of Python3.8):
/usr/local/opt/python#3.8/bin/python3 -m notebook
Also if you want to install packages for that version:
/usr/local/opt/python#3.8/bin/pip3 install that_package
in the official jupyter dcoumentation, there is a description now to do it, when customizing jupyter stacks. I think the mamba command will solve the problem. The commands starting with RUN can also just executed on a linux system.
# Choose your desired base image
FROM jupyter/minimal-notebook:latest
# name your environment and choose the python version
ARG conda_env=python37
ARG py_ver=3.7
# you can add additional libraries you want mamba to install by listing them below the first line and ending with "&& \"
RUN mamba create --quiet --yes -p "${CONDA_DIR}/envs/${conda_env}" python=${py_ver} ipython ipykernel && \
mamba clean --all -f -y
# alternatively, you can comment out the lines above and uncomment those below
# if you'd prefer to use a YAML file present in the docker build context
# COPY --chown=${NB_UID}:${NB_GID} environment.yml "/home/${NB_USER}/tmp/"
# RUN cd "/home/${NB_USER}/tmp/" && \
# mamba env create -p "${CONDA_DIR}/envs/${conda_env}" -f environment.yml && \
# mamba clean --all -f -y
# create Python kernel and link it to jupyter
RUN "${CONDA_DIR}/envs/${conda_env}/bin/python" -m ipykernel install --user --name="${conda_env}" && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# any additional pip installs can be added by uncommenting the following line
# RUN "${CONDA_DIR}/envs/${conda_env}/bin/pip" install --quiet --no-cache-dir
# if you want this environment to be the default one, uncomment the following line:
# RUN echo "conda activate ${conda_env}" >> "${HOME}/.bashrc"
Hope this helps
after restart my ubuntu 16.04, could not find pip
I can only get my original pip via python3 -m pip freeze
if I use pip freeze there shows bash: /usr/bin/pip: No such file or directory
And I installed my jupyter via pip install and I could not use jupyter notebook command now. It shows jupyter: command not found
And I make sure I use sudo apt-get update and when I want to install a new jupyter with sudo apt-get install jupyter-notebook it shows
E: Unable to locate package jupyter-notebook
Seems several system configuration go wrong? How to recover these? How can I open my jupyter?
bash: /usr/bin/pip: No such file or directory
Verify the file /usr/bin/pip exists. If it does check the first line:
head -1 /usr/bin/pip
The line (called shebang) must be something like #!/usr/bin/python. If it isn't edit the file and fix the shebang line to point to an existing python binary.
I installed my jupyter via pip install and I could not use jupyter notebook command now. It shows jupyter: command not found
It's because pip installed jupyter into a directory not in $PATH. Most probably /usr/local/bin/. Check the directory with pip show --files jupyter and add the directory to your $PATH both in the current shell and in your ~/.bash_profile.
I want to install a new jupyter with sudo apt-get install jupyter-notebook it shows E: Unable to locate package jupyter-notebook
Try sudo apt-get update.
The pip problem has been solved.
The reason is that PATH is somehow modified and it loses the ~/.local/bin, the original pip is in this path and pip also install jupyter notebook in this path.
After I added ~/.local/bin to PATH I can run pip and jupyter notebook, in brief this is a path problem
I want to change the Jupyter notebook theme, so I installed the themes with:
pip install jupyterthemes
The installation seems working fine but when I try to change the theme:
jt -t <theme_name>
I get:
jt: command not found
I tried to uninstall the themes:
pip uninstall jupyterthemes
but I got:
Skipping jupyterthemes as it is not installed
During the installation I got no error though.
What should I do to install the themes properly?
I'm using Ubuntu 16.04, and I installed Jupyter Notebook with pip. Jupyter works fine, it's just the themes that don't work
I solved the issue without sudo access by inputting commands within a Jupyter notebook.
Input the following in the cell of a notebook:
!pip install jupyterthemes
jt commands should work well afterward.
Simply run this. I was facing same issue, it worked
.
sudo pip install jupyterthemes
Go to your bash terminal and execute these commands
$ pip install jupyterthemes
$ ls .local/bin/
$ .local/bin/jt -l
$ .local/bin/jt -t chesterish
If you are trying to change the theme from inside the Jupyter notebook just use the below code.
!jt -l # to see the list of available themes
!jt -t <theme_name> # to set a theme
For example:
!jt -t monokai
I am a ubuntu user, and I have install python 2.7.9 on my computer.
In order to use jupyter notebook, I down load anaconda2.
After my installation, I find after entering the command 'jupyter notebook', my browser will open jupyter notebook, but I can't find new python2, so I went to the https://ipython.readthedocs.org/en/latest/install/kernel_install.html
Use the following commands:
conda create -n ipykernel_py2 python=2 ipykernel
source activate ipykernel_py2
python -m ipykernel install --user
Now I do can new python2 on the jupyter notebook, but when I enter the command 'from pylab import *'
it will show the error as ImportError: No module named pylab
but if I open a terminal and enter 'python' and then enter 'from pylab import *', it works all ok.
So, what is the problem? I am new to python and jupyter notebook.
Thank you very much.
I find the problem.
In terminal:
ipython
In [1]: import sys
In [2]: sys.path
Out[2]:
['',
'/home/hust/anaconda2/bin',
'/home/hust/anaconda2/lib/python27.zip',
'/home/hust/anaconda2/lib/python2.7',
'/home/hust/anaconda2/lib/python2.7/plat-linux2',
'/home/hust/anaconda2/lib/python2.7/lib-tk',
'/home/hust/anaconda2/lib/python2.7/lib-old',
'/home/hust/anaconda2/lib/python2.7/lib-dynload',
'/home/hust/.local/lib/python2.7/site-packages',
'/home/hust/anaconda2/lib/python2.7/site-packages',
'/home/hust/anaconda2/lib/python2.7/site-packages/Sphinx-1.3.5-py2.7.egg',
'/home/hust/anaconda2/lib/python2.7/site-packages/setuptools-20.3-py2.7.egg',
'/home/hust/.local/lib/python2.7/site-packages/IPython/extensions',
'/home/hust/.ipython']
But in jupyter notebook, the sys.path is:
['',
'/home/hust/anaconda2/envs/ipykernel_py2/lib/python27.zip',
'/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7',
'/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/plat-linux2',
'/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/lib-tk',
'/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/lib-old',
'/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/lib-dynload',
'/home/hust/.local/lib/python2.7/site-packages',
'/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/site-packages/setuptools-20.7.0-py2.7.egg',
'/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/site-packages',
'/home/hust/.local/lib/python2.7/site-packages/IPython/extensions',
'/home/hust/.ipython']
Then I remember I have used the following codes to create a python2 kernel.
conda create -n ipykernel_py2 python=2 ipykernel
source activate ipykernel_py2
python -m ipykernel install --user
In the website's description, if you’re running Jupyter on Python 3, you can set up a Python 2 kernel like this. But actually I am running Jupyter on Python 2, the reason why I could not new a python2 script in jupyter notebook should be something else.
Finally, I realize that it is better to master all the pythons' environment via pyenv. I should firstly install pyenv and then I only need use these commands, pyenv install anaconda-2.4.0 , pyenv global anaconda-2.4.0 and jupyter notebook.
I would like to use another theme for Ipython notebook so I following this instructions the problem is I'm in OSX and I dont have the wget, I installed it homebrew. Could somebody help me to set ipython notebooks in a dark theme?. I tried this:
brew /Users/user/.ipython/profile_notebooks/static/custom/custom.css
https://raw.githubusercontent.com/nsonnad/base16-ipython-notebook/master/base16-ocean-dark.css
You can do it with curl or by manually downloading the theme. I have given steps for both the options below.
Create a custom profile using the following command:
ipython profile create ocean
Replace the content of the default stylesheet custom.css with that of the required theme using the following command
Using curl:
curl -o `ipython locate profile ocean`/static/custom/custom.css https://raw.githubusercontent.com/nsonnad/base16-ipython-notebook/master/base16-ocean-dark.css
Start the IPython notebook by specifying the custom profile e.g.
ipython notebook --profile=ocean
Alternative:
If you are not able to download using curl, you can simply download the base16-ocean-dark.css and replace the custom.css in the custom directory of your created profile.
Locate the profile directory:
ipython locate profile ocean
Go to its static/custom directory and replace the content of custom.css with that of downloaded css file.
Start the IPython notebook by specifying the custom profile as shown above.
Amit's answer isn't fit for ipython=>4.0, as jupyter is divided from it now.
You can try jupyter-themes.
It is suit for ipython=>4.0 and much more easy to install.
Install jupyter-themes
$ pip install --upgrade jupyterthemes
Pick a theme and install
# list themes (located in ~/.jupyter-themes)
$ jt -l
# install theme (-t) for jupyter nb
# theme names: oceans16 | grade3 | space-legos
$ jt -t grade3
# install a theme (-t) with toolbar (-T) enabled
$ jt -T -t grade3
# install a theme (-t) and set font-size (-f), default value is 11
$ jt -f 12 -t grade3
# reset (-r) to default for jupyter theme
$ jt -r
I've added jupyter-themes to pypi under the name jupyterthemes.
To install the latest version:
#uninstall any old versions
pip uninstall jupyter-themes
#install the latest version (no hyphen)
pip install jupyterthemes
Hopefully that takes care of any issues people were having with themes not showing up (#llya).