Terminal problem- jupyter notebook

Hey Everyone! I recently started having a problem opening Jupyter notebook in my terminal and I was wondering if anyone could help me. I am super new to using the terminal and to coding in general so I am pretty lost. I have opened Jupyter notebook several times and completed the exercises but the last time I tired it gave me this error:

-bash: /Users/name/.bash_profile: line 2: syntax error near unexpected token >' -bash: /Users/name/.bash_profile: line 2: >>> conda initialize >>>’
Names-Air:~ name$ jupyter notebook
-bash: jupyter: command not found

Is there a relatively easy fix to this? I really want to be able to finish the python program I have been working on.

Thanks so much! :slight_smile:

I think there’s a problem within the .bash_profile file with some invalid syntax. Since that line (and probably the lines near it) seem to be setting up conda for bash you miss adding various conda commands to your shell environment.

In short your .bash_profile is wrong and means jupyter notebook isn’t on your PATH.

If you can work out what line is causing the issue then you can fix it; or, if you’re not sure then remove all the conda lines from this file (.bash_profile) and run conda init bash to get conda to add them back for you (for a bash shell). Close and re-open your terminal at this point.

Also, one more thing…are you on a Mac? If so, what OS?
If it’s Catalina or Big Sur, then the default is no longer bash but .zsh. So, your profile would be zsh not bash (unless you specified it to be bash when you downloaded anaconda).

1 Like

I’m sorry, life got crazy and I am just getting able to get back to this. I am on a Mac that is High Sierra. Thank you so much for the info but I am such a beginner, I am still a bit confused. Could you tell me which lines to delete? Thanks so much again!

export PATH="/Users/name/.local/bin:$PATH"

conda initialize >>>

!! Contents within this block are managed by ‘conda init’ !!

__conda_setup="('/opt/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ ? -eq 0 ]; then
eval “$__conda_setup”
else
if [ -f “/opt/miniconda3/etc/profile.d/conda.sh” ]; then
. “/opt/miniconda3/etc/profile.d/conda.sh”
else
export PATH="/opt/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup

<<< conda initialize <<<

Setting PATH for Python 3.9

The original version is saved in .bash_profile.pysave

I put my code in Shellcheck and I think the problem is that I am missing a # before <<< conda initialize >>> in line 2. Does that seem correct?

That should definitely be commented out, yes. It’s not a command. If I ask conda (anaconda in this case but it’s almost the same) to initialise bash it looks like the following-

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda/etc/profile.d/conda.sh"
    else
        export PATH="/opt/anaconda/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Everything between # >>> conda initialize >>> and # <<< conda initialize <<< is a line added by conda. It seems likely you can fix your issue simply by correctly commenting out the section you mentioned.

Please also see the following- How do I format code in my posts? because with the markup used on the forums it is very hard for anyone else to read the code you’ve pasted.

Hi all - I’ve got a similar issue after having followed the Codecademy video on Pipenv, which did not work and ended up messing up with my Mac terminal and now I cannot access Jupiter Notebook. I think it’s got something to do with the changes/deletions I made to PATH following the video, but I’m a complete rookie when it comes to any of this so I’m literally stuck. Could someone pls guide me through it? I tried reinstalling stuff too but no matter what I do I always get the “command not found” message. Thanks!
[UPDATE] - managed to install Anaconda Navigator throuhg which I can access Jupyter, which is good. How can now access this trhough the terminal as I would have before by only needing to type in “Jupyter Notebook” the launch the application?Thnx!

1 Like

Got it fixed! Thanks so much!

1 Like

Glad to hear you got sorted, if I’m not mistaken the pipenv video is now a little out of date for OSX. The default shell is now zsh instead of bash so .bash_profile may not be sourced. You’d want to be editing the relevant .zsh configs instead- macos - ZSH: .zprofile, .zshrc, .zlogin - What goes where? - Ask Different (.zshrc is suggested).