Skip to content

Latest commit

 

History

History

Troubleshooting Lessons

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Troubleshooting Instructions

TROUBLESHOOTING LESSONS (Copy of LP)


Table of Contents:

    1. Kernel Error / Jupyter Missing "Python (dojo-env)" in kernels
    2. conda activate error - GitBash
    3. "code" Command Not Working (Mac)
    4. GitBash Error: Could Not Fork Child Process
    5. Installing Graphviz (Windows)
    6. Reinstalling Dojo-Env
    7. Uninstalling Anaconda (Completely)
    8. GitBash Opens in the Wrong Folder



1. Kernel Error / Jupyter Missing "Python (dojo-env)" in kernels

PROBLEM:

  • If you see a message like this when trying to open the environment testing notebook:

  • OR if "Python (dojo-env)" doesn't show up in Jupyter Notebook in EITHER:
    • The "New" menu on the Files tab in Jupyter.

    • or the Kernel > Change Kernel menu inside a Jupyter Notebook:

Solution

  • You missed a command after running the conda env create command during step 2, so let's rerun the command.
  • First, shut down Jupyter Notebook
    • The quickest way is to go back to the Terminal/GitBash window that you used to start the notebook and press "control + C"
  • In your terminal/GitBash, make sure it says (dojo-env) above or next to your terminal prompt.
    • if not, on Mac run:
      • "conda activate dojo-env"
    • on Windows run:
      • "source activate dojo-env"
  • Then run the command below to install dojo-env as a kernel in jupyter:
python -m ipykernel install --user --name dojo-env --display-name "Python (dojo-env)"

Then, go ahead and boot up jupyter notebook and try again. It should now know the "Python (dojo-env)" kernel.




2. conda activate error - GitBash

PROBLEM:

  • You see the following error message in GitBash:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
    $ conda init <shell_name>
Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell
See 'conda init --help' for more information and options.</shell_name>

Solution 1:

  • For your computer, run "source activate dojo-env" instead of conda activate.
    • ANYTIME you see a set of instructions that says to run "conda activate" you should ALWAYS replace the word "conda" with "source".
source activate dojo-env

PROBLEM - V2:

  • If you are seeing this message EVERY time you open a new GitBash Window.

Solution 2:

  • During step 2, you were told to run the following echo conda activate command but your computer requires you to use "source activate" instead of "conda activate"
## INCORRECT What you ran previously
echo "conda activate dojo-env" >> ~/.bash_profile
  • Step 1) To fix this, you need to open the hidden file ".bash_profile" in VS Code to fix the command.
    • In GitBash run the following command to open the file in VS Code.
code ~/.bash_profile
  • If this doesn't work and says file not found, change the "~./" to your full file path to your user folder:
    • In the example below, replace <USERFOLDER> with your actual User account name.


      • Note: if you do not know your username, run the "whoami" command in GitBash. The text displayed is your <USERFOLDER>
code /c/Users/<USERFOLDER>/.bash_profile


  • Step 2) in the vs code window that opens, you should see the 3 lines of text below.
conda activate dojo-env
alias jnb="jupyter notebook"
alias lab="jupyter lab"
  • Replace the word "conda" with "source" and then click on File > Save.
    • So your final .bash_profile should now say:
source activate dojo-env
alias jnb="jupyter notebook"
alias lab="jupyter lab"

(Note: it is okay if there is additional text in this file. Whats important is that you change the conda activate command to source activate.)


  • Step 3) Open a NEW GitBash window and the message should no longer appear!




3. "code" Command Not Working (Mac)



  • If you are trying to open VS Code using the "code" command in your Terminal and receive an error message that says
command not found: code
  • Open VS Code manually (check the Applications folder or use Spotlight Search)
  • Open the Command Palette.
    • On the menu bar (top of the screen), select "View" > and then select "Command Palette"

  • A popup window will appear with a ">" prompt.


  • Start typing "install code" and you should see the option appear for "Shell Command: Install 'code' command in PATH".
    • Click on this option.

  • It will then notify you that you will be prompted to give "osascript" administrative privileges.



  • Click OK and then on the next pop-up window, enter your normal password for your Mac.
    • You should see a success message like the one below.

  • You are all set! Try the code command again.


  • NOTE: if you get an error message when running the install code command:
    • First UNinstall the code command (which is counter-intuitive).
    • Then rerun the install code command.



4. GitBash Error: Could Not Fork Child Process

The Problem:

Opening a GitBash windows displays an error message "Could not fork child process"

enter image description here


The Solution

Solution 1: (adapted from: https://rotadev.com/git-bash-error-could-not-fork-child-process-there-are-no-available-terminals-1-dev/ )

  • The problem occurs on Windows with Git Bash when the Git Bash console is closed/killed without using ‘exit’.
    • 1. Close all Git Bash windows.
    • 2. Open Task manager (Keyboard shortcut: Control + Shift + Escape.)
    • 3. Find the ‘Git for Windows’ process.
      • If you do not see any "Git for Windows" processes, look for:
        • python
        • msys2
    • 4. Kill any processes that are running that meet the above criterion.
    • 5. Re-open Git Bash. The problem should be fixed.
    • See the Prevention heading below for how to avoid this error in the future

Solution 2 (if #1 did not resolve the issue):

  • The problem may also occur due to VS Code's integrated terminal.
  • Close any Visual Studio Code windows
  • Check Task Manager for any Visual Studio Code processes that are still running and kill them.
  • Re-open Git Bash. The problem should be fixed.
  • See the Prevention heading below for how to avoid this error in the future

Solution 3 (will always work but not convenient)

  • If neither solution worked, restart your computer.
  • While not convenient, it will solve the issue. See the Prevention heading below for how to avoid this error in the future.


Prevention

  • Always make sure to shut down jupyter notebook properly before closing.
    • From jupyter's file view:
      • Click Shutdown on the top right corner
    • From GitBash:
      • Press "Control + C" to quit jupyter server from the GitBash window that started jupyter notebook.
        • If asked y/n, answer "y".






5. Installing Graphviz (Windows)

Graphivz is an optional package that will allow you to generate a more advanced version of scikit-learn decision tree plots.







6. Reinstalling Dojo-Env


What to do if your environment breaks and you need to re-install it.

  • It is not uncommon to accidentally break our virtual environment by installing a new package or updating a pre-existing one.
  • In the event that your environment stops working and it needs to be re-installed:
    1. open your terminal/gitbash and deactivate your dojo-env:
      • Type conda activate base or conda deactivate and press enter.
      • Your terminal should now say (base) with your prompt instead of (dojo-env).
    2. Remove the broken dojo-env using the command:
      • conda remove --name dojo-env --all
      • enter y to approve the removal of the environment and hit enter.
    3. Wait for the env to be removed.
      • This will delete all of the files associated with JUST our dojo-env. So anconda will still be installed, we will just need to re-install our dojo-env.
    4. Once its completed, repeat the environment installation commands from step "2.3 Create the dojo-env environment"
      1. Don't forget to run the python -m ipykernel command after creating the dojo-env in step 2.3!



7. Uninstalling Anaconda (Completely)

When facing stubborn environment problems, sometimes the best course of action is to completely uninstall the environment AND Anaconda and to start over.

Pre-Uninstallation Verification Step:

  • If you share your computer with another User who also uses Python:
    • Pause here and check with them BEFORE you uninstall anaconda. You will be removing all of their python environments too, even though they have a separate User account.
  • If you share your computer with someone and they have concerns about uninstalling anaconda:
    • Stop here (for now).
      • Do not move forward with the instructions until you have spoken with your instructor.


Official Steps for Fully Uninstalling Anaconda:

The following steps are taken directly from the Official Uninstalling Anaconda documentation page, specifically "Option B. Full uninstall using Anaconda-Clean and simple remove."

  • Install the Anaconda-Clean package from Anaconda Prompt (terminal on Linux or macOS):
conda install anaconda-clean
  • In the same window, run the following command:
anaconda-clean --yes
  • Once the process has been completed, manually delete any "anaconda3" or "anaconda2" folders that still exist.
    • It may be located in one of several possible folders. Run the following "ls -a" commands until you see a folder called "anconda2" or "anaconda3".
    • Once you see an anaconda folder, take note of:
      • Which command showed the folder.
        • Specifically, what did the command say after "ls -a"
        • We will refer to this as your "base folder" in the final step.
      • If the anaconda folder was "anconda2" or "anaconda3"
        • We will refer to this as your "anaconda folder" in the final step.
    • and jump to the very last command at the bottom of the page, with those 2 pieces of information.
ls -a ~/
ls -a ~/opt/
ls -a /opt/
  • Run the final command to remove the anaconda folder once you've identified your "base folder" and "anaconda folder".
    • Replace {base_folder} with the actual folder name
    • Replace {anaconda_folder} with the actual folder name.
rm -rf {base_folder}{anaconda_folder}


Once you've replaced the placeholder folder names with your actual folder names, the command should look something like this:

rm -rf ~/opt/anaconda3
# or 
rm -rf ~/anaconda2
# or 
rm -rf ~/opt/anaconda3

Final Verification Step:

  • Now, open a new terminal window and try running the "conda" command again. Your terminal should say that conda is not found.
    • If it says conda is not found, you are now ready to jump back up to the "Step 3 Commands" header above.
  • Open the two settings file for your terminal and remove anything related to anaconda:
    • 1) Run the "open ~/.bash_profile" (without quotation marks) command and a text editor window should open.
      • Examine the contents of this file and delete any lines that look like either of the screenshots below:

      • Save the file and close it.
    • 2) Now repeat the process, but use the "open ~/.zshrc" (without quotation marks) command
      • Delete any lines of code that look like the screenshots above.
      • Save the file and close it.


  • FInal Verification:
    • Open a New Terminal Window (the changes you made above only take effect when opening a new window)
    • Run the "conda" command again and you should now see a message that says "conda not found"
      • If you are still seeing the list of conda commands instead, re-open the two files listed above and make sure you saved them after deleting the lines of code.
      • Close your terminal window and open a new one and try the "conda" command again.


  • If the conda command still displays the list of commands after the steps above:
    • Try restarting your computer and attempting to run the command one more time.
    • If you are still seeing conda commands:



8. GitBash Opens in the Wrong Folder

PROBLEM:

Opening GitBash from Windows start menu (not from Github Desktop) and starting jupyter notebook displays a folder containing bin/cmd/dev/etc ( see screenshot below) instead of the expected User folder with Documents/Downloads/etc.


Cause

Your GitBash program defaults to the folder where GItBash is installed. What you are seeing above is the contents of C:/Program Files/GitBash. This happens to a small percentage of windows users.


Solution/Workaround

  • First, run the following echo command to add one more alias to GitBash and then open a new GitBash window
echo 'alias ~="$HOME"' >> ~/.bash_profile
  • Now test the command by runing the commands below to change directory to "~" and to display the current folder name.
cd ~
ls
  • If you can see your Downloads, Desktop, Documents, etc. folders then the alias worked!

New Workflow

  • From now on, if you want to open a GitBash in your user folder, you will run "cd ~" as soon as you open a new GitBash window.
    • Note: if you are opening a specific repo from GitHub Desktop you will NOT want to run this command, since you are already in the desired folder.