Problems setting up a new theme in Ipython? - python

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).

Related

Changing jupyter notebook theme from windows cmd

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).

What is the default install path for poetry

I installed poetry, however I'm getting the following error when attempting to call poetry
zsh: command not found: poetry
I know I have it installed because I get the following output when trying to run the following install script
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
Retrieving Poetry metadata
Latest version already installed.
The default install location is ~/.poetry/bin/poetry
I added the following to my .zshrc
export PATH=$PATH:$HOME/.poetry/bin
Initially I wanted to run poetry within a condo environment. After running
pip install poetry
I saw it was installed using my local Python and not linked to a conda environment. In my case I added
export PATH="$HOME/.local/bin:$PATH"
to the end of the .zshrc file under my home directory.
Tip: You can use CMD+Shift+. for MacOS to view your hidden files and folders :)
Update for the new version of the official poetry installer:
curl -sSL https://install.python-poetry.org | python3 -
This version will install in your default python3 bin. For example: $HOME/Library/Python/3.9/bin, the installer will print out the location to your shell.
Add
export PATH=$HOME/Library/Python/3.9/bin:$PATH
to ~/.profile or ~/.zprofile.

pip configuration go wrong after ubuntu restart

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

"jt: command not found"

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

Why can't I find ansible when I install it using setup.py?

Because I had some trouble with Ansible (I'm on mac) which seemed to be fixed in the latest dev version today I uninstalled ansible through pip (sudo pip uninstall ansible) and reinstalled the latest dev version from the github repo using the classic setup.py method, which seemed to end successfully (full output here.
So then I tried using it:
$ ansible --version
-bash: ansible: command not found
$ which ansible
$
I checked where it is installed. From the full output I linked to above I found that it is installed in /usr/local/lib/python2.7/site-packages, and indeed in there I find an egg:
$ ls -l /usr/local/lib/python2.7/site-packages | grep ansible
drwxr-xr-x 4 root admin 136 Aug 22 16:33 ansible-2.4.0-py2.7.egg
When I start Python and check the site-packages folder I find a different folder:
>>> import site; print site.getsitepackages()[0]
/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
but that is a symlink to the same folder:
$ ls -l /usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
lrwxr-xr-x 1 hielke admin 54 Aug 13 22:36 /usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages -> ../../../../../../../../../lib/python2.7/site-packages
So I guess the problem is that no symlink is created to the ansible package in /usr/local/bin/. But I'm unsure how I could create such a symlink and why it wouldn't appear in the first place.
Does anybody know how I can move forward from here? All tips are welcome!
When you invoke ansible from the shell, bash will search in your $PATH for a file named ansible that is executable. This may not be the only issue, but this is the immediate cause for the error you're seeing. The .egg file itself is not an executable, it's just a file used for distributing the code.
If ansible has been installed correctly, you should be able to find it by using locate or the OSX Finder GUI. The name should match exactly, with no file extensions. You will probably also find ansible-connection, ansible-console, etc. in the same place where you find the ansible executable. If you find it, great! Test it out and add that directory to your $PATH in a terminal like so:
export PATH=$PATH:/path/to/ansible
Where /path/to/ansible is the directory where you found the executables. This change to the $PATH variable is temporary, and will go away when you close your shell. If you can now run ansible from bash, then you can make the change permanent by adding that export to the end of your $HOME/.bash_profile file, or by adding a rule in /etc/paths.d (recommended by Apple). See more on how exactly to do those here if you are unfamiliar with them.
Now, if that's not the problem and you can't find the ansible executable, then the installation itself is your problem. You might also try using a virtual environment (if you have it installed) to make sure that the version you're pulling from github isn't broken:
git clone https://github.com/ansible/ansible.git
cd ansible
virtualenv venv
source venv/bin/activate
pip install .
which ansible
As of this writing, the above gives me a working ansible install.
For those using the Windows 10 Ubuntu terminal, running this command should fix the issue:
export PATH=$PATH:~/.local/bin
Find where ansible reside on your Mac. Most times its /Users/<yourusername>/Library/Python/3.7/bin
or /Users/<yourusername>/Library/Python/2.7/bin. Then ...
export PATH=$PATH:/Users/<yourusername>/Library/Python/3.7/bin
You can store this in your .bashrc file.
Well, I think you just need to create a soft link
ln -s /Users/${yourname}/Library/Python/${python version}/bin/ansible /usr/local/bin/ansible
pip3 install ansible --user
this installs in ~/.local. just include this in PATH, it will work
example: export PATH="$PATH:~/.local/bin"
I faced same issue when I installed ansible. Run the below commands to solve the issue. But we have to active each time when we open a bash session if we want to use ansible.
$ python -m virtualenv ansible
$ source ansible/bin/activate
$ pip install ansible
I'm using zsh so in my /Users/arojas/.zshrc I add this line that's where my Ansible got installed by Python
export PATH="$PATH:$HOME/Library/Python/3.7/bin"
I faced the same issue and after have installed it used pip3 install ansible it all works now.
I suggest uninstalling Ansible and re-installing it using pip according to the method suggested in the Ansible docs:
Or if you are looking for the latest development version:
pip install git+https://github.com/ansible/ansible.git#devel
If you are installing on OS X Mavericks, you may encounter some noise from your compiler. A workaround is to do the following:
$ sudo CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install ansible
Readers that use virtualenv can also install Ansible under virtualenv, though we’d recommend to not worry about it and just install Ansible globally. Do not use easy_install to install ansible directly.
system/instance used: ec2 RH8, as root
# pip3 install ansible (not recommended - should be by a user)
# ansible --version ( not found - wtf?!)
# yum install mlocate
# update
# locate ansible (long output; scroll to where you input command)
# export PATH=$PATH:/usr/local/bin
# ansible --version (success, Yes!)
system/instance used: ec2 RH8, as root
# pip3 install ansible (not recommended - should be by a user)
# ansible --version ( not found - :( )
# yum install mlocate
# updatedb (updatedb creates or updates a database used by locate)
# locate ansible (TL;DR)
# export PATH=$PATH:/usr/local/bin (Add this line to .bashrc)
# source .bashrc (To reflect the changes in the bash)
# ansible --version (success, Yes!)

Categories