Failed to run IPython Notebook: bash: IPython: command not found - jupyter-notebook

I've installed Ipython 6.0.0 successfully using Pip3:
pip3 install IPython
but when tried to run the command
Ipython
I got this error:
bash: IPython: command not found
This is the pip list result:
ipykernel (5.1.3)
ipython (6.0.0)
ipython-genutils (0.2.0)
..
..
notebook (6.0.2)
and this is the result of pip3 show IPython
Name: ipython
Version: 6.0.0
Summary: IPython: Productive Interactive Computing
Home-page: https://ipython.org
Author: The IPython Development Team
Author-email: ipython-dev#python.org
License: BSD
Location: /home/pi/.local/lib/python3.5/site-packages
Requires: setuptools, traitlets, jedi, pexpect, pygments, pickleshare, simplegeneric, prompt-toolkit, decorator

This is a problem of case sensitivity...
The correct typography is IPython.
pip is not case sensitive, see Is PyPI case sensitive?
IPython is installed as ipython (lowercase), as shown in your pip3 show IPython
bash is case sensitive...
So, just enter ipython.
As you have specified pip3, I would also recommend to invoke ipython3 to avoid python2/3 confusions.

Related

How to enable Stata kernel in jupyter notebook

I am using MacOS and try to use Stata in the jupyter notebook. I went over the following step to do so.
First, in the terminal:
pip install stata_kernel
python -m stata_kernel.install
conda install -c conda-forge nodejs -y
jupyter labextension install jupyterlab-stata-highlight
pip install ipystata
And then in my jupyter notebook:
import ipystata
from ipystata.config import config_stata
config_stata('/Macintosh HD⁩/Applications/Stata/StataSE')
import ipystata
%%stata
display "Hello, I am printed in Stata."
But I keep getting the error message
UsageError: Line magic function %%stata not found.
I am not sure if this is path problem or something else.
Could you help me to fix the problem?

Jupyter Notebook Export Fails with "nbconvert failed: Inkscape svg to pdf conversion failed"

When I try to export a Jupyter notebook to pdf format, I receive the following error. nbconvert failed: Inkscape svg to pdf conversion failed. What's causing the error?
This is currently an open issue it seems like: https://github.com/jupyter/nbconvert/issues/1325
But for me installing the nbconvert 6.0.0 version worked. In that version the code that #Raoul mentions has been modified:
pip install nbconvert==6.0.0
You also need to have Inkscape installed + make sure you can open inkscape from the terminal. In MacOS i had to do this:
ln -s /Applications/Inkscape.app/Contents/MacOS/inkscape \
/usr/local/bin/inkscape
I think where exactly the executable is depends on your version of inkscape. But if you have the latest version, it should be the same. Essentially typing inkscape in the terminal should open inkscape. That's what you want.
The error occurs because export to pdf software isn't installed. Use the following commands to install the missing software. Commands shown are for debian distributions such as Ubuntu.
sudo apt update && sudo apt upgrade
sudo apt install inkscape pandoc texlive-xetex texlive-fonts-recommended texlive-generic-recommended
On Mac OSX and Anaconda distribution I was facing the same problem. I discovered that the problem is in the /Applications/anaconda3/lib/python3.7/site-packages/nbconvert/preprocessors/svg2pdf.py file.
According to https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line
inside this file you have some lines (which I commented out) which are obsolete and need to be replaced with the following.
class SVG2PDFPreprocessor(ConvertFiguresPreprocessor):
"""
Converts all of the outputs in a notebook from SVG to PDF.
"""
#default('from_format')
def _from_format_default(self):
return 'image/svg+xml'
#default('to_format')
def _to_format_default(self):
return 'application/pdf'
command = Unicode(
help="""The command to use for converting SVG to PDF
This string is a template, which will be formatted with the keys
to_filename and from_filename.
The conversion call must read the SVG from {from_filename},
and write a PDF to {to_filename}.
""").tag(config=True)
# #default('command')
# def _command_default(self):
# return self.inkscape + \
# ' --without-gui --export-pdf="{to_filename}" "{from_filename}"'
#default('command')
def _command_default(self):
return self.inkscape + \
' --export-type="pdf" "{to_filename}" "{from_filename}"'
Also be sure that you have installed Inkscape:
I have downloaded and installed the dmg
I have also Symlink the binary: sudo ln -s /Applications/Inkscape.app/Contents/MacOS/inkscape /usr/local/bin
And I have changed the path:
raoul#mbp-de-raoul ~ % export PATH=/Applications/anaconda3/bin:$PATH
raoul#mbp-de-raoul ~ % jupyter --version
jupyter core : 4.6.1
jupyter-notebook : 6.0.3
qtconsole : 4.6.0
ipython : 7.12.0
ipykernel : 5.1.4
jupyter client : 5.3.4
jupyter lab : 1.2.6
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.4
traitlets : 4.3.3
And restarted the server
Now the export File > Download As > pdf is working.
You can try the following steps
pip install --upgrade nbconvert
sudo apt-get install texlive-xetex texlive-fonts-recommended texlive-plain-generic
pip install altair_saver
I had this same problem on Ubuntu, and what fixed it for me was installing according their apt repo, as suggested on the Inkscape Wiki.
sudo apt-get install inkscape

Some problems with installing JupyterLab

Installed JupiterLab, but ran into a problem in the terminal.
> Terminals not available (error was No module named 'winpty.cywinpty')
Tried the following commands:
First
pip install pywinpty
Requirement already satisfied: pywinpty in c:\python38\lib\site-packages (0.5.7)
Second (version)
Python --version 3.8.3
jupyter-lab --version
2.1.5
ipython --version
7.16.1
Third
import winpty
conda install pywinpty
and others don't get rid of startup errors
On Windows it can be solved by installing pywinpty from the wheel provided here: https://www.lfd.uci.edu/~gohlke/pythonlibs/ .
Just download (the wheel) and install it via:
pip install -I the_wheel_name_you_have_downloaded

How to install a nbextension with python and js components as a labextension

I created a nb extension following this link!. The extension works correctly when ran from:
jupyter notebook
When I ran the same extension from
jupyter lab
The extension does not work and gives me an error:
Error displaying widget: model not found
Here is the error on console:
Could not instantiate widget
(anonymous) # manager-base.js:273
09:27:26.891 default.js:127 Error: Module test_pp, semver range 1.2.0 is not registered as a widget module
at WidgetManager.loadClass (manager.js:251)
test_pp is the extension module I am trying to run.
Following are the commands that make the extension work in notebok:
python setup.py build
pip install -e .
jupyter nbextension install --py test_pp
jupyter nbextension enable --py test_pp
jupyter notebook
Folder structure of notebook extension:
test_pp
js
lib
embed.js
extension.js
index.js
labplugin.js
test_pp.js <------ The javascript part of extension
node_modules
package.json
webpack.config.js
test_pp
static
__init__.py
_version.py
test_pp.py <-------- The extension server side python
Looking thru several tutorials and blogs I found some commands that I could run that should make it but, but they did not help:
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
jupyter labextension install #jupyter-widgets/jupyterlab-manager
cd jupyter_lab_src/test_pp
jupyter labextension install . <----- Fails, not a valid npm package
cd js <----- as that folder has package.json
jupyter labextension install . <---- installs successfully
jupyter lab
Open a notebook from lab, call the same commands that work in jupyter notebook:
from test_pp import test_pp
pp = test_pp.PostProcessor()
pp.initWidget()
data = 1
pp.set_data(data)
pp
Gives the error I described above. Ran a command to see the extensions:
(base) C:\data\OnScale_Jupyter\jupyterlab\test_pp>jupyter labextension list
JupyterLab v1.1.3
Known labextensions:
app dir: c:\users\anils\miniconda3\share\jupyter\lab
#jupyter-widgets/jupyterlab-manager v1.0.2 enabled ok
test_pp v0.1.0 enabled ok* <----- why is there a star
local extensions:
test_pp: C:\data\OnScale_Jupyter\jupyterlab\test_pp\js
I see an error on the conda command console as well:
[W 10:22:31.781 LabApp] Failed to fetch package metadata for 'test_pp': <HTTPError 404: 'Not Found'>
I believe, in essence, I am unsure of how to launch a nbextension as a labextension?
Any help would be appreciated?
Previously, I had the same issue. Here is what I did.
First, I installed the nbextension using the command in conda prompt.
(https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html)
Then I enabled hinterland in nbextension in jupyternotebook. But still, it doesn't work in jupyter lab.
Then I followed instructions mentioned in this link:
https://jupyterlab.readthedocs.io/en/stable/user/extensions.html#id14
installed nodejs using the below command:
conda install -c conda-forge nodejs
Then I rebuild my jupyterlab using the command:
jupyter lab build
Then I could see docstring and other autofill extension working in jupyterlab, as in this image.

jupyter not found after pip install jupyter

After many different ways of trying to install jupyter, it does not seem to install correctly.
May be MacOS related based on how many MacOS system python issues I've been having recently
pip install jupyter --user
Seems to install correctly
But then jupyter is not found
where jupyter
jupyter not found
Not found
Trying another install method found on SO
pip install --upgrade notebook
Seems to install correctly
jupyter is still not found
where pip /usr/local/bin/pip
What can I do to get the command line jupyter notebook command working as in the first step here: https://jupyter.readthedocs.io/en/latest/running.html#running
Short answer: Use python -m notebook
After updating to OS Catalina, I installed a brewed python: brew install python.
It symlinks the Python3, but not the python command, so I added to my $PATH variable the following:
/usr/local/opt/python/libexec/bin
to make the brew python the default python command (don't use system python, and now python2.7 is deprecated). python -m pip install jupyter works, and I can find the jupyter files in ~/Library/Python/3.7/bin/, but the tutorial command of jupyter notebook doesn't work. Instead I just run python -m notebook.
My MacOS has python 2.7, I installed python3 with brew, then the following commands work for me
brew install python3
brew link --overwrite python
pip3 install ipython
python3 -m pip install jupyter
You need to add the local python install directory to your path. Apparently this is not done by default on MacOS.
Try:
export PATH="$HOME/Library/Python/<version number>/bin:$PATH"
and/or add it to your ~/.bashrc.
Try solving this with Conda or Poetry.
Poetry makes it a lot easier to manage Python dependencies (including Jupyter) and build a virtual environment.
Here are the steps to adding Jupyter to a project:
Run poetry add pandas jupyter ipykernel to add the dependency
Run poetry shell to create a shell within the virtual environment
Run jupyter notebook to to fire up a notebook with access to all the virtual environment dependencies
The other suggested solutions are just band-aids. Conda / Poetry can give you a sustainable solution that's easy to maintain and will shield you from constant Python dependency hell.

Resources