4

I have been using Conda Miniforge for almost few months to accomplish my ML tasks on Apple Silicon Chip (a.k.a M1). However, yesterday I was trying to install a package with conda (i.e., conda install conda-forge name-of-package) and the moment I executed the command, the terminal returns (without any error or output) to accept new command as everything executed normally. After a while, I switched into my virtual environment and then open python shell to import Tensorflow then zsh killed the python as you can see below:

(mlm1-engine) mohammadkasrahabib@iste Downloads % python
Python 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 15:50:57) 
[Clang 11.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
zsh: killed     python
(mlm1-engine) mohammadkasrahabib@iste Downloads % 

Importing any package related to ML (sklearn, Matplotlib or etc.) will kill the python, but it works fine I import the ordinary python packages, e.g. math.

Another thing is non of the conda commands work except conda --version; terminal shows that command runs without any error, but no output. You can see it bellow:

(mlm1-engine) mohammadkasrahabib@iste ~ % conda list
(mlm1-engine) mohammadkasrahabib@iste ~ %   
(mlm1-engine) mohammadkasrahabib@iste ~ % conda info
(mlm1-engine) mohammadkasrahabib@iste ~ %          
(mlm1-engine) mohammadkasrahabib@iste ~ % conda env list
(mlm1-engine) mohammadkasrahabib@iste ~ % 
(mlm1-engine) mohammadkasrahabib@iste ~ % conda --version
conda 4.10.0
(mlm1-engine) mohammadkasrahabib@iste ~ % 

And also running the commands with sudo will output that the command is killed by zsh. As you can see it bellow:

(mlm1-engine) mohammadkasrahabib@iste ~ % sudo conda env list
Password:
zsh: killed     sudo conda env list
(mlm1-engine) mohammadkasrahabib@iste ~ % 

Any help would be much appreciated! Thanks in Advance!

2 Answers2

1

Check your python3 version. I upgraded to 3.9.12 and had the same problem. I returned back to 3.9.10 and that solved the problem.

0

The questions you should ask yourself:

  • Did you change something with conda? eg: update it, delete some files, etc.?
  • What is the last package that you (successfully) installed? Is there a reason to believe that this one (or one of its dependencies) is responsible for your problem?
  • Do you have different results when the environment is (de)activated?
  • Does it work with bash (rather than zsh)?*

If you answer no to all of the above, your best course of actions is to reinstall conda all together, simple as that.

[EDIT]

* To check whether it works with bash:

  1. Open a terminal (with bash NOT zsh, check with echo $SHELL. You might have to edit your .bashrc or terminal emulator settings)
  2. Run eval "$(<PATH_TO_ANACONDA>/bin/conda shell.bash hook)"
  3. Run conda update -n base conda

[UPDATE]

None of the approaches worked, I re-installed it. Everything works fine! But still, that was weird!

qmeeus
  • 2,341
  • 2
  • 12
  • 21
  • Here are answers to your questions: - I did not changed any settings for my conda. - The last package I installed was Stanford NLP, around a month ago. I also tried to install a few other packages, in case the problem might be only with this one. - conda behaves the same either virtual environment is active or not active. - Does it work with bash? What do you mean you mean configuring it with `conda init bash`. Installing conda is one option, but I keep that for the worst-case; since I do not want to reinstall everything again. This is the weirdest problem I have ever faced – Mohammad Kasra Habib Apr 21 '21 at 11:59
  • I mean: if zsh seem to kill your process each time, maybe it's worth trying with bash instead to see if the problem persist. I will add the command to test on bash in my answer. Note that if the problem turns out to be with anaconda and not with zsh, then you will probably gain a lot by just reinstalling. In my experience, trying to fix a broken anaconda is just a waste of time and effort – qmeeus Apr 21 '21 at 12:07
  • Another question: did you install packages with pip or with conda? If you installed them with pip, it is very much possible that it broke some things (saying that pip is not the best package manager is an understatement) – qmeeus Apr 21 '21 at 12:08
  • Ok, I did changed to `bash`, this time it kills the process with the ***signal 9***. I assume this is the same thing as happened with `zsh`. I only used to install `tensorflow` with pip (I guess this is the only way to install it on an apple with an m1 chip) and some other packages which are not available for `conda`. I am using ***`conda miniforge3`***, since the `conda` commands do not work to remove it; what is the best way to properly remove it from my system. – Mohammad Kasra Habib Apr 21 '21 at 13:01
  • `rm -rf ` will delete your anaconda installation. – qmeeus Apr 21 '21 at 13:08
  • So, it doesn't have more dependencies to take care of??? – Mohammad Kasra Habib Apr 21 '21 at 13:09
  • You might want to check this: https://github.com/apple/tensorflow_macos/issues/48#issuecomment-739959831 – qmeeus Apr 21 '21 at 13:12
  • No anaconda and miniconda are entirely self-contained, removing the folder is enough to uninstall – qmeeus Apr 21 '21 at 13:13
  • I've just installed miniforge. But, every time I run ```conda``` on my zsh, I only get ```zsh: killed conda```. I tried all of the above steps, but nothing seems to work. Coudl someone help me? https://stackoverflow.com/questions/68911815/zsh-killed-conda-after-adding-it-to-path – AnonymousMe Aug 25 '21 at 08:27