All of the sudden, my terminal stopped recognizing the 'conda'. Also the VS Code stopped seeing my environments.
All the folders, with my precious environments are there (/opt/anaconda3), but when I type conda I get:
conda
zsh: command not found: conda
I tried install conda again (from .pkg) but it fails at the end of installation (no log provided).
How can I clean it without losing my envs?
I use Apple M1 MacBookPro with Monterey.
To recover conda if it has disappeared and you're getting a "command not found" error, follow these steps:
Check if conda is installed on your system by running the command:
which conda
If the above command doesn't return anything, you may need to add the path to your conda installation to your PATH environment variable. To find the path, run the following command:
find / -name conda 2>/dev/null
Add the path to your .bashrc or .bash_profile file:
export PATH="/bin:$PATH"
Restart your terminal or run the following command to reload your environment variables:
source ~/.bashrc
Try running conda again to see if it's working.
If conda is still not working, it may have been uninstalled or moved. In that case, you can reinstall conda from the Anaconda website or from the Miniconda website.
For some reason my .zshrc file was corrupted after some operations.
This prevented terminal to call conda init and in general, to have 'conda' call understandable.
What is more - this prevented installing any condas, minicondas, minoforge. Both from .pkg and .sh - annoyingly - without any log, information - just crash and goodbye.
I cleared both .zshrc' and .bash_profile` and then it helped - I managed to install minigorge and have my 'conda' accessible from terminal.
Unfortunately, in the process I removed all my previous 'envs'.
Related
I’m on osX Catalina. When in the Terminal I’m doing an echo $PATH, here is the output :
/Users/Nicolas/opt/anaconda3/bin:/Users/Nicolas/opt/anaconda3/condabin:/Users/Nicolas/.poetry/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
I realized that I need to reorder the PATH because when I’m trying to create a virtual environment with pipenv install requests the output is command not found: pipenv despite having it installed.
After reading posts and tutorials, here is what I’m doing to (try to) correct the issue :
I move into the home directory in the terminal
A create a .zsh file with the command : nano .zsh
I add the following :
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
export PATH=$PATH:/Users/Nicolas/.local/bin
The first export is to reorder the PATH, the second line is an answer to the following warning that I had when installing pipenv :
WARNING: The scripts pipenv and pipenv-resolver are installed in ‘/Users/Nicolas/.local/bin’ which is not on PATH.
Then I save the file, exit, reboot the computer. When I’m running the echo $PATH again, nothing changed.
What am I doing wrong ?
You may want to try re-installing with Homebrew
brew uninstall pipenv
brew install pipenv
pipenv install requests
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
I am new to programming and would appreciate help.
I had been running code successfully but recently installed conda, which is causing issues.
Sys.executable shows
C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\pythonw.exe
in IDLE and
C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\python.exe in
the command prompt.
However, when I run a script from my desktop calling sys.executable in the command prompt, it shows P:\conda\python.exe. When I run other scripts from files on my desktop it also can no longer import modules, which are stored in the same folder as my original Python installation.
My question is: how can I change the interpreter for the files I am running from my desktop so that they can find the correct modules?
I have read all of StackOverflow's ModuleNotFound and sys.executable related threads but cannot fully understand what is going on - thanks for the help.
create new python environment on conda as follows and run your code on new env:
Actually using conda and conda navigator is the better approach
After conda installation:
- Open up the conda command prompt and create your working environment as follwos
conda create -n mytestenv python=3.7
Activate the environment:
conda activate mytestenv
Now, Run your code.
Later on if you need any module, Install your module using conda command on your selected environment, for example
conda install numpy
I have quite some problems using python on my Mac. I need different versions from 3.5 to 3.7 and multiple packages for data science. Due to various instructions on the web I ended up installing python 3.6 itself, anaconda, pipenv and maybe more stuff I can't even remember.
I suppose there is no other way to eliminate this mess than to format everything and start over. Currently my terminal is showing some sort of prefix for the environment in the terminal. Something like:
(base) user#machine:~$:
How can I at least get rid of this environment prefix? It appeared after installing pipenv, which seems to have taken over my previous anaconda environments. I fear those vanish to when uninstalling pipenv.
The deactivate command alone will get you out of the currently activated virtual environment.
(base) user#machine:~$:
(base) user#machine:~$: deactivate
user#machine:~$:
As far as I know, this works across all operating systems.
Found the problem: Anaconda edited the .bash_profile which gets executed on the mac for each new terminal. I deleted the anaconda entry and the base prefix is gone.
Also, for anyone that is using zsh and Anaconda.
You can remove the entry Anaconda makes from the ~/.zshrc file in addition to the conda deactivate
Conda can be configured with command conda config
This command will remove message about the current environment:
conda config --set changeps1 no
This command will add messages about the current environment:
conda config --set changeps1 yes
https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#change-command-prompt
What is the recommended approach for installing Anaconda on Mac?
I tried with brew cask install anaconda which after a while returns anaconda was successfully installed!.
After that - trying conda command returns command not found: conda.
Is there any post step installation that needs to be done?
And what is recommended way to install Conda on MacOS?
brew install anaconda
export PATH="/usr/local/anaconda3/bin:$PATH"
I would say that the recommended way to install anaconda is to use the official anaconda installer, which can be downloaded from the link I just posted. I've done it several times, never had a problem, and it walks you through it (including an option to automatically add it to your PATH).
New answer using only the terminal for mac zsh
This is how I did it only using the terminal and apple's now default zsh:
# - install python
# install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# install wget to get miniconda
brew install wget
# get miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
# source /Users/my_username/opt/anaconda3/bin/activate
source ~/miniconda/bin/activate
conda init zsh
conda update -n base -c defaults conda
conda install conda-build
conda create -n iit_synthesis python=3.9
conda activate iit_synthesis
#conda remove --name metalearning2 --all
inspired from: How do I use Conda in on Homebrew Python system?
Old answer
I don't know about other people but I've had issue downloading conda/miniconda etc for a few hours now. For some reason it decided to install at ~/opt when using the graphical installer (i.e. the .dmg file). I've been through the uninstall here How to uninstall Anaconda completely from macOS and additionall did an rm -rf ~/opt command. Seems that without this its not actually uninstalled (you might also have to change your PATH or .bash_profile or .bashrc until your path is virigin again before you start your re-installation installation). Seems that using the command line installer is what works:
Anaconda3 will now be installed into this location:
/Users/brandBrandoParetoopareto/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/Users/brandBrandoParetoopareto/anaconda3] >>>
PREFIX=/Users/brandBrandoParetoopareto/anaconda3
Unpacking payload ...
Collecting package metadata (current_repodata.json): done
Solving environment: done
So for that download it from the official link then do:
sh Anaconda3-2020.02-MacOSX-x86_64.sh
do sh I believe is the right thing because I might have had issue in the past when I did bash instead...plus if you are using a different shell like zsh I am not sure what you'd need to do, but I'd get sh would be safest.
After the installation is done you should do:
conda init <SHELL-NAME>
so that conda is initialized correctly (so far that seems to only modify my .bash_profile and my PATH variable). Unfortunately, it seems the previous uninstallation attempts didn't remove the code the previous conda init had added from my .bash_profile so I removed it manually using vim.
This is what I get after doing that:
conda init bash
no change /Users/brandBrandoParetoopareto/anaconda3/condabin/conda
no change /Users/brandBrandoParetoopareto/anaconda3/bin/conda
no change /Users/brandBrandoParetoopareto/anaconda3/bin/conda-env
no change /Users/brandBrandoParetoopareto/anaconda3/bin/activate
no change /Users/brandBrandoParetoopareto/anaconda3/bin/deactivate
no change /Users/brandBrandoParetoopareto/anaconda3/etc/profile.d/conda.sh
no change /Users/brandBrandoParetoopareto/anaconda3/etc/fish/conf.d/conda.fish
no change /Users/brandBrandoParetoopareto/anaconda3/shell/condabin/Conda.psm1
no change /Users/brandBrandoParetoopareto/anaconda3/shell/condabin/conda-hook.ps1
no change /Users/brandBrandoParetoopareto/anaconda3/lib/python3.7/site-packages/xontrib/conda.xsh
no change /Users/brandBrandoParetoopareto/anaconda3/etc/profile.d/conda.csh
modified /Users/brandBrandoParetoopareto/.bash_profile
==> For changes to take effect, close and re-open your current shell. <==
if you are using vs-code integrated terminal like I am you need to press the trash can button. Doing bash seems to NOT re-run your .bash_profile so make sure you do what it would consider "closing your terminal and re-opening it completely".
That should be all you need to do I believe. Perhaps you also need to make sure you have the most recent version of mac OS.
Extra tips hints
Make sure conda init modified your .bash_profile correctly. For me for some reason it added it's stuff AFTER it ran my .bashrc and thus when my .bashrc tried activating my environment it wouldn't do it as it would say conda wasn't initialized correctly (and thus nio matter how many times I re-ran conda init <SHELL> it wouldn't fix it. I don't know why that happened but that's how it was.
I avoided the dmg/graphical installation since it seemed to install it at non-standard places ~/opt
If conda is still acting weird it might be because of the way your .bashrc modifies the PATH env variable. What worked for me was removing lines that modified my path in .bashrc (AND having the code conda init added before my .bashrc was ran).
inspired from:
https://askubuntu.com/questions/505919/how-to-install-anaconda-on-ubuntu/1412558#1412558
https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html
mac provides the nice renaming and downloading to location: https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html
How to install wget in macOS?
After installation using the graphical installation, everything sits in the ~/opt directory, as mentioned in some previous answers. If this is OK for you, all you need to do to use the command line conda is add ~/opt/anaconda3/bin in your path. This can be done by adding
export PATH="${PATH}:~/opt/anaconda3/bin"
at the end of your rc file (~/.zshrc or ~/.bashrc).