lllyasviel / Fooocus

Focus on prompting and generating
GNU General Public License v3.0
38.07k stars 5.08k forks source link

[Bug]: CondaError: Run 'conda init' before 'conda activate' #3235

Closed rgaufman closed 1 day ago

rgaufman commented 3 days ago

Checklist

What happened?

I have a clean installation and I'm following the steps:

1. Install the conda package manager and pytorch nightly. Read the [Accelerated PyTorch training on Mac](https://developer.apple.com/metal/pytorch/) Apple Developer guide for instructions. Make sure pytorch recognizes your MPS device.
2. Open the macOS Terminal app and clone this repository with git clone https://github.com/lllyasviel/Fooocus.git.
3. Change to the new Fooocus directory, cd Fooocus.
4. Create a new conda environment, conda env create -f environment.yaml.
5. Activate your new conda environment, conda activate fooocus.

I am stuck on step 5:

Romans-MacBook-Pro.local ➜  Fooocus git:(main) conda init
no change     /opt/homebrew/anaconda3/condabin/conda
no change     /opt/homebrew/anaconda3/bin/conda
no change     /opt/homebrew/anaconda3/bin/conda-env
no change     /opt/homebrew/anaconda3/bin/activate
no change     /opt/homebrew/anaconda3/bin/deactivate
no change     /opt/homebrew/anaconda3/etc/profile.d/conda.sh
no change     /opt/homebrew/anaconda3/etc/fish/conf.d/conda.fish
no change     /opt/homebrew/anaconda3/shell/condabin/Conda.psm1
no change     /opt/homebrew/anaconda3/shell/condabin/conda-hook.ps1
no change     /opt/homebrew/anaconda3/lib/python3.12/site-packages/xontrib/conda.xsh
no change     /opt/homebrew/anaconda3/etc/profile.d/conda.csh
no change     /Users/hackeron/.bash_profile
No action taken.
Romans-MacBook-Pro.local ➜  Fooocus git:(main) conda activate fooocus

CondaError: Run 'conda init' before 'conda activate'

Any ideas?

Steps to reproduce the problem

  1. Follow instructions
  2. Get to conda activate foocus step
  3. Observe error: CondaError: Run 'conda init' before 'conda activate'
  4. Confirm that conda init does not resolve the problem

What should have happened?

It should allow going to the next step

What browsers do you use to access Fooocus?

No response

Where are you running Fooocus?

Locally

What operating system are you using?

Mac 15.0

Console logs

As above

Additional information

No response

mashb1t commented 3 days ago

Did you open a new terminal / zsh session after installing anaconda? Also see https://docs.anaconda.com/reference/troubleshooting/

rgaufman commented 2 days ago

I did open a new terminal, yes.

I am not seeing the "Run 'conda init' before" in the above troubleshooting link, so I'm not sure how to proceed.

mashb1t commented 2 days ago

@rgaufman ensure your .bashrc / .zshrc is correctly set up.

export PATH=/usr/local/anaconda3/bin:$PATH
export PATH=/opt/homebrew/anaconda3/bin:$PATH
which conda
conda () {
    \local cmd="${1-__missing__}"
    case "$cmd" in
        (activate | deactivate) __conda_activate "$@" ;;
        (install | update | upgrade | remove | uninstall) __conda_exe "$@" || \return
            __conda_reactivate ;;
        (*) __conda_exe "$@" ;;
    esac
}

Then run

conda env create -f environment.yaml
conda activate fooocus
rgaufman commented 1 day ago

Thank you for your reply, I already added this to my .zshrc before I created this issue:

export PATH="/opt/homebrew/anaconda3/bin:$PATH"

I'm able to run the conda command, so it's in the path. Adding the "conda () {..." stuff breaks the conda command:

$ conda env create -f environment.yaml
conda:6: command not found: __conda_exe

If I remove it, back to this:

$ conda env create -f environment.yaml

CondaValueError: prefix already exists: /opt/homebrew/anaconda3/envs/fooocus

$ conda activate fooocus

CondaError: Run 'conda init' before 'conda activate'

I always open a new terminal session whenever I make changes to ~/.zshrc

I don't know why this is happening or what to do next :(

mashb1t commented 1 day ago

Something is messed up in your zshrc. I'd recommend removing everything related anaconda from it and initializing again. conda init has to write the anaconda code to the zshrc in irder to work.

rgaufman commented 1 day ago

Nothing was messed up, I just figured it out! - conda init wasn't using .zshrc, it was using .bash_profile, I added this to my .zshrc and now got past that step:

export PATH="/opt/homebrew/anaconda3/bin:$PATH"
source ~/.bash_profile

Will report back if I get stuck, thank you :)

rgaufman commented 1 day ago

It worked, thank you! - Closing.