How to solve the problem 'zsh: command not found: jupyter' - python

I bought Macbook air M1, and I tried to install jupyter notebook with this code.
pip3 install --upgrade pip
pip3 install jupyter
and I tried to open jupyter notebook with this code.
jupyter notebook
but, then, this code appeared.
zsh: command not found: jupyter
enter image description here

First, you need to find where it was installed.
pip3 show jupyter | grep Location
Example:
$ pip3 show pip | grep Location
Location: /usr/lib/python3/dist-packages
Then you need to ensure that the path you get is in your PATH.
Example:
$ export PATH=/usr/lib/python3/dist-packages:$PATH

Try adding Python's bin/ folder path to $PATH variable.
You should be able to find it here - /Users/<your-username>/Library/Python/3.x/bin
Step 1 : Open .bash_profile in text editor
open ~/.bash_profile
Step 2 : Add the following line at the end of the file
export PATH="/Users/<your-username>/Library/Python/3.x/bin:$PATH"
Step 3 : Save the edits made to .bash_profile and restart the terminal

This issue and many others are bound to happen with Jupyter. There are many tools that install Jupyter and they all do it a bit differently.
To sidestep the whole problem of clunky installs, try a desktop "click and run" app for Jupyter.
For macOS and iOS, that's Callisto. It's currently in the beta stage so you can try it out for free (it even lets you connect to cloud servers for running your notebooks!)
For reference: This comment has a good solution for fixing pip3 install on macOS
Good luck!

Related

Python was not found after closing commandline. Windows opens app store when I type python

I have downloaded and installed python from here.
Then I restarted and opened a commandline and typed
python --version
I recorded all my actions, so I can post a screenshot of that:
It works and shows the version number.
Then I performed the following steps to install Jupyter because I want to use a local runtime with Google Colab:
In the Windows commandline (not in the Python window!!), I type this:
pip install virtualenv
python -m pip install --upgrade pip
virtualenv opencv (I guess I can choose a random name here because we will not be using OpenCV, right? But for simplicity, I keep this name now)
I CD to c:\users\MYUSERNAME\opencv\Scripts
activate.bat
pip install numpy
python -m pip install jupyter
Now my browser opens this page: http://localhost:8888/tree
Now I click "New" and "Python 3 (ipykernel)"
Now I want to install the extension jupyter_http_over_ws.
I type:
pip install jupyter_http_over_ws
Nothing shows up when I type text on the keyboard. It looks like this:
Because I want to be able to type again, I close the command line and open it again.
Now I type again:
pip install jupyter_over_http_ws
It says
The command "pip" has been misspelt oder was not found.
Because I have no idea what is happening, I type:
python --version
I am expecting that it shows the version number like before.
But instead it shows
"Python was not found."
Why is that?
ps: When I type "python", it starts the Microsoft App Store and offers me to download it:
Thank you!
What happens if you add your python installation path to the environment variables?
https://www.educative.io/answers/how-to-add-python-to-path-variable-in-windows
Don't forget to restart Windows after adding the path!

zsh within juypter notebook not recognizing any commands

I have confirmed and ran it on my local terminal but it will not recognize any commands in juypter notebook for some reason...
screenshot of error
First, please confirm that jupyter has been installed correctly.
pip3 install --upgrade pip
pip3 install jupyter
Find the installation location of jupyter
pip3 show jupyter
You will get a result similar to the following
According to location, we can find the location of jupyter
/Library/Frameworks/Python.framework/Versions/3.7/bin/
Then add this location to the path searched by the command. (Be careful not to add spaces on both sides of the equal sign when assigning)
vim ~/.zshrc (or .bashrc if bash)
Add the following statement
export PATH=/Library/Frameworks/Python.framework/Versions/3.7/bin/:$PATH
Then reload the relevant command
source.zshrc
Use jupyter
jupyter notebook
Hope this helps you

can't run ipython on cmd

I successfully installed ipython via pip. I wanted then to use it by launching it through windows 10 command prompt but am getting the following error
'ipython' is not recognized as an internal or external command,
operable program or batch file.
I have gone through many questions on stackoverflow but cannot get a relevant solution.
I tried pip install ipython to confirm the ipython is installed and following on the instruction on my tutorial, i typed ipython on cmd to launch the program and it has never worked. This is slowing down my learning, please help!
Found the solution: run python -m IPython (case sensitive).
To find that out, I ran pip show ipython and it showed me some info, including the path of the module (for me: c:\users\mathieures\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages). In there, a folder named IPython!
Search in your machine the ipython application (directory in which it is installled) and the add the path to PATH environment variables.
For example in my case location was C:\Users\DELL\AppData\Local\Programs\Python\Python37\Scripts
Add this path to PATH environment variable (see here) and your problem is solved.
for first uninstall ipython python -m pip uninstall ipython then install ipython with code python -m pip install ipython when finished type ipython to run.
I had the same problem, and what i simply did is uninstall it using pip uninstall ipython and then reinstall it using pip install ipython like the same as what Ali vatankhah did but without adding python -m in the command.

Pandas and Jupyter not found after upgrading to Catalina

I just updated my macOS to Catalina and I can't run python or open a jupyter notebook from terminal anymore. As an example, I get error message "ImportError: No module named pandas" when running my python code, and I get
zsh: command not found: jupyter
when running
jupyter notebook
This issue has brought me to anaconda (I would love someone to explain me why. Does python need anaconda to be ran?). I have tried several suggestions from https://github.com/ContinuumIO/anaconda-issues/issues/10998, e.g. I have tried copying folder "anaconda3" from "Relocated items" folder to "Users//", then
export PATH=''/Users/<username>/anaconda3/bin:$PATH"
but I get either
dquote>
or
zsh: /Users//Applications/anaconda3/bin/conda: bad interpreter: /anaconda3/bin/python: no such file or directory
I then tried to reinstall Anaconda using the graphic installer (from https://www.anaconda.com/distribution/#macos) following advice from someone from the anaconda team (https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/) (I changed installation location to a folder I created in /Users//) but I still get the same error messages when running python3 or jupyter notebook.
How can successfully run python and jupyter notebook with macOS Catalina?
After installed macOS Catalina, we can switch the terminal from bash to zsh. There are many advantages from using zsh instead of bash, but One of the issues with zsh is some of the frameworks (jupyter notebook,conda) are not supported directly. Once I typed jupyter notebook in terminal to run it. It displayed “zsh: no such file or directory”.
The solver is simple but very difficult to find online.
If jupyter was already installed before the update and stopped working after zsh, you should be able to fix it by:
1.open zshrc in terminal by typing: open .zshrc or $open .zschrc
2. add the following line at the end of the file:
source ~/.bash_profile
It will ask zsh to use all the information from bash like the path of jupyter.
Hope it can help you out!
I'm answering to my own question in case it can help others ;)
I found my answer here: https://medium.com/#singhaniatanay18/mac-os-catalina-update-zsh-instead-of-bash-d688f68f70b8
(see comments as well)
Mac OS BigSur:
Uninstall Anaconda:rm -f Anaconda-Navigator.app
re-install pip3 install jupyterlab
I just updated to Catalina, two days before Big Sur release.. oh well.
Catalina came with changes to security and bash, that will remain for future releases. So Catalina moves your anaconda3 folder to /Users/Shared/Previously Relocated Items/Security/anaconda3 I tried to move it back to home directory, but that didn't work. So I deleted it, and reinstalled Anaconda using the command line installer Not the GUI installer, and it worked for me. You can follow instructions here and use /Users/me/anaconda3 folder as recommended here.
Here are the commands that worked for me,
shasum -a 256 /Users/username/anaconda3 . Although not sure it did anything
bash ~/Downloads/Anaconda3-2020.02-MacOSX-x86_64.sh or whatever the name of the command line installer from Conda in your Download folder, or wherever else you downloaded it.
Use sudo in front of the command if permission was denied, then enter your log in password for your Mac
source /Users/username/anaconda3/bin/activate conda init zsh
sudo conda init zsh then enter your Mac's password.
You should be all set now, and all commands like ipython, conda info, jupyter notebook, pyspark will all work.
The last command will make step3 command persist i.e. initialize conda base environment, such that you can run conda, ipython, jupyter notebook the next time you use terminal.
Install the Jupyter using Homebrew in zsh shell
If you don't Python install 3.3or higher.
Open terminal
Using Homewbrew install jupyter
brew install jupyter
Now, you start a notebook
jupyter notebook

Solving "500: Internal Server Error, nbconvert failed: xelatex not found in PATH"

Whenever I try to export a Jupyter notebook as a PDF I get the following error in a separate window:
500 : Internal Server Error
The error was:
nbconvert failed: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.
I am running macOS Sierra 10.12.6.
Things I have tried:
Re-installing nbconvert through pip (in the Jupyter notebook) and conda (terminal)
Installing xelatex for Mac
Re-installing Mactex
Installing pandoc (both through pip and through "conda install -c conda-forge pandoc")
Running
!echo $PATH
Yields:
/Users/ed/anaconda/bin:/Users/ed/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin
I located the directory containing xelatex as per #einsweniger suggestion here: /usr/local/texlive/bin/x86_64-darwin. I copied and pasted XeLatex into the bin directory above, and get a new error:
nbconvert failed: PDF creating failed, captured latex output:
warning: kpathsea: configuration file texmf.cnf not found in these directories: /Users/e/anaconda/bin:/Users/ed/anaconda/bin/share/texmf-local/web2c:/Users/ed/anaconda/bin/share/texmf-dist/web2c:/Users/ed/anaconda/bin/share/texmf/web2c:/Users/ed/anaconda/bin/texmf-local/web2c:/Users/ed/anaconda/bin/texmf-dist/web2c:/Users/ed/anaconda/bin/texmf/web2c:/Users/ed/anaconda:/Users/edefilippis/anaconda/share/texmf-local/web2c:/Users/e/anaconda/share/texmf-dist/web2c:/Users/ed/anaconda/share/texmf/web2c:/Users/ed/anaconda/texmf-
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)
kpathsea: Running mktexfmt xelatex.fmt
I can't find the format file `xelatex.fmt'!
I also put xelatex.fmt in the directory, but am still getting the error.
I encountered the same issue. As people previously stated, the problem lies in that xlatex isn't found in your PATH environment variable.
A solution that worked for me was to run the following from the notebook:
!export PATH=/Library/TeX/texbin:$PATH
Or in a command line simply:
export PATH=/Library/TeX/texbin:$PATH
And then run the export to pdf from a command line (within your virtual environment if there is one in place) as follows:
jupyter nbconvert your_notebook.ipynb --to pdf
This should create a pdf of your notebook on the same directory it is running.
$ sudo apt-get install texlive-xetex texlive-fonts-recommended texlive-plain-generic
I'm not accustomed with Mac install paths, from what the basictex faq says, I gather the executeables should live in /usr/local/texlive/bin/x86_64-darwin
Running which xelatex in a terminal might also help finding where the command is, but that only works if the directory is already in your PATH variable.
Another method would be running find / -name 'xelatex' if it is not within your PATH so you might find it that way (might take a while as this will search you whole harddrive).
Once you've found it and added the path to your PATH variable, you should also check if the jupyter has the correct PATH by running
import os
print(os.environ['PATH'])
within a notebook.
On mac, you can install mactex using homebrew with the following: brew install --cask mactex
I know this question is long answered, but I just ran into this issue and found a very easy, codeless solution: print to PDF.
Thought I might post this here for anyone else who doesn't feel like figuring out path variables or updating a zillion different things. Your browser's print function probably works just fine.
I've run into similar issues in the past with paths in python when using tensorflow in Windows and Linux. As is pointed out by others, using PATH is the way to go (i.e update in .bashrc if it was linux), but I've found the code below to resolve path issues on a script by script basis.
import sys
if "\your\path\to\xelatex" not in sys.path:
print('adding path') # I just add this to know if the path was present or not.
sys.path.append("\your\path\to\xelatex")
essentially would check PATH for what it is you are looking for and then adds it if it is missing. You probably don't even need the 'if' statement.
Perhaps not the most practical way has worked well for me where I know the path in question is perhaps a 'rarely used' or 'one time use' PATH add...
So as was pointed out in comments above (and I think you already have) find the location of the file and add its location using the above code.
Some more reading on it:
https://docs.python.org/3/tutorial/modules.html
6.2 Standard Modules
If (You are using jupyter the easier way I found was to)
Download the file in latex.
Upload it to overleaf.
And then download it as a pdf
Else if ( You are using google collab)
Download as ipynb
Upload to jupyter and repeat the above steps.
Windows users can save the .ipynb file as a HTML file and print the HTML file to save it as PDF with custom settings.
If there is an update available maybe try and update Jupyter
Add "env": {"PATH":"$PATH"} to your kernel.json, for me that was in /opt/anaconda3/share/jupyter/kernels/python3/kernel.json.
JupyterLab or Anaconda seems to override the system PATH by default, if you set this then the PATH will be the same in JupyterLab and in your shell, so if you have anything custom installed like xelatex, it will show up in JupyterLab.
Run this command in your jupyter terminal (or in your environment if you have any), close all jupyter notebook tabs and reopen it then convert the notebook to pdf
pip install --upgrade --user nbconvert
How to install latex and xelatex on Mac so that Jupyter "Download as PDF" will work
brew install pandoc
brew tap homebrew/cask
brew cask install basictex
eval "$(/usr/libexec/path_helper)"
# Update $PATH to include `/usr/local/texlive/2020basic/bin/x86_64-darwin`
sudo tlmgr update --self
sudo tlmgr install texliveonfly
sudo tlmgr install xelatex
sudo tlmgr install adjustbox
sudo tlmgr install tcolorbox
sudo tlmgr install collectbox
sudo tlmgr install ucs
sudo tlmgr install environ
sudo tlmgr install trimspaces
sudo tlmgr install titling
sudo tlmgr install enumitem
sudo tlmgr install rsfs
More info here
Close all the anaconda runing programs and then,open conda command prompt and try the following command:
conda install -c conda-forge pandoc
Update/Reinstall Anaconda if not updated.
now install chromium through link https://chromium.woolyss.com/download/en/ and make it default browser.
Then run jupyter notebook using this browser.
Lastly use option "Download as" in jupyter notebook and then select the option using PDF via pyppeteer (.html)
HOLA!! It worked..

Categories

Resources