Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named conda.cli.main #2463

Closed
tanweihou opened this issue May 11, 2016 · 24 comments
Closed

No module named conda.cli.main #2463

tanweihou opened this issue May 11, 2016 · 24 comments
Labels
locked [bot] locked due to inactivity source::community catch-all for issues filed by community members
Milestone

Comments

@tanweihou
Copy link

Hi all, I encountered problem with conda after I updated packages
After executing conda update --all, I freed up some spaces with conda clean -pity
It is similar to issue #2200

username@userpc:~> conda
Traceback (most recent call last):
  File "/username/anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main
username@userpc:~> conda list
Traceback (most recent call last):
  File "/username/anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main
username@userpc:~> . activate myenv
bash: activate: No such file or directory
username@userpc:~> which activate
which: no activate in ($PATH)
username@userpc:~> 

I checked the root environment directory and found that some symbolic link files are broken, eg. activate, deactivate
Those files are pointed to conda .pkgs directory, which was cleaned with conda clean -pity
Any ideas how to recover it, or reinstall conda ?

@ijstokes
Copy link

Definitely looks like a bug on our part. Conda should never take actions that will cripple itself.

You may be able to repair things using this strategy:

#1733 (comment)

Can you see if you can figure out the conda version you were using that caused this problem? conda -V won't work, but perhaps:

import conda
conda.__version__

if it is importable. And if not, maybe pydoc conda? (although that will probably have the same issue if it isn't importable...) Finally, you could figure it out by looking at:

cat /username/anaconda/lib/python2.7/site-packages/conda/__init__.py

@ijstokes
Copy link

Hah, glad I read this earlier today, because moments ago this happened to me (using conda v4.0.5). Observe in trace below:

demo@ip-172-31-55-246:~$ conda create -n jupyter jupyter notebook anaconda 
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ....
Solving package specifications: .........

Package plan for installation in environment /home/demo/.conda/envs/jupyter:

The following NEW packages will be INSTALLED:

    alabaster:          0.7.7-py27_0       (soft-link)
    anaconda:           4.0.0-np110py27_0  (soft-link)
    anaconda-client:    1.4.0-py27_0       (soft-link)
    anaconda-navigator: 1.1.0-py27_0       (soft-link)
    argcomplete:        1.0.0-py27_1       (soft-link)
    astropy:            1.1.2-np110py27_0  (soft-link)
    babel:              2.2.0-py27_0       (soft-link)
    backports_abc:      0.4-py27_0         (soft-link)
    beautifulsoup4:     4.4.1-py27_0       (soft-link)
    bitarray:           0.8.1-py27_0       (soft-link)
    blaze:              0.9.1-py27_0       (soft-link)
    bokeh:              0.11.1-py27_0      (soft-link)
    boto:               2.39.0-py27_0      (soft-link)
    bottleneck:         1.0.0-np110py27_0  (soft-link)
    cairo:              1.12.18-6          (soft-link)
    cdecimal:           2.3-py27_0         (soft-link)
    cffi:               1.5.2-py27_0       (soft-link)
    chest:              0.2.3-py27_0       (soft-link)
    cloudpickle:        0.1.1-py27_0       (soft-link)
    clyent:             1.2.1-py27_0       (soft-link)
    colorama:           0.3.7-py27_0       (soft-link)
    conda-manager:      0.3.1-py27_0       (soft-link)
    configobj:          5.0.6-py27_0       (soft-link)
    cryptography:       1.3-py27_0         (soft-link)
    curl:               7.45.0-0           (soft-link)
    cycler:             0.10.0-py27_0      (soft-link)
    cython:             0.23.4-py27_0      (soft-link)
    cytoolz:            0.7.5-py27_0       (soft-link)
    dask:               0.8.1-py27_0       (soft-link)
    datashape:          0.5.1-py27_0       (soft-link)
    decorator:          4.0.9-py27_0       (soft-link)
    dill:               0.2.4-py27_0       (soft-link)
    docutils:           0.12-py27_0        (soft-link)
    dynd-python:        0.7.2-py27_0       (soft-link)
    enum34:             1.1.2-py27_0       (soft-link)
    et_xmlfile:         1.0.1-py27_0       (soft-link)
    fastcache:          1.0.2-py27_0       (soft-link)
    flask:              0.10.1-py27_1      (soft-link)
    flask-cors:         2.1.2-py27_0       (soft-link)
    fontconfig:         2.11.1-5           (soft-link)
    freetype:           2.5.5-0            (soft-link)
    funcsigs:           0.4-py27_0         (soft-link)
    futures:            3.0.3-py27_0       (soft-link)
    gevent:             1.1.0-py27_0       (soft-link)
    greenlet:           0.4.9-py27_0       (soft-link)
    grin:               1.2.1-py27_1       (soft-link)
    h5py:               2.5.0-np110py27_4  (soft-link)
    hdf5:               1.8.15.1-2         (soft-link)
    heapdict:           1.0.0-py27_0       (soft-link)
    idna:               2.0-py27_0         (soft-link)
    ipaddress:          1.0.14-py27_0      (soft-link)
    ipykernel:          4.3.1-py27_0       (soft-link)
    ipython:            4.1.2-py27_1       (soft-link)
    ipython_genutils:   0.1.0-py27_0       (soft-link)
    ipywidgets:         4.1.1-py27_0       (soft-link)
    itsdangerous:       0.24-py27_0        (soft-link)
    jbig:               2.1-0              (soft-link)
    jdcal:              1.2-py27_0         (soft-link)
    jedi:               0.9.0-py27_0       (soft-link)
    jinja2:             2.8-py27_0         (soft-link)
    jpeg:               8d-0               (soft-link)
    jsonschema:         2.4.0-py27_0       (soft-link)
    jupyter:            1.0.0-py27_2       (soft-link)
    jupyter_client:     4.2.2-py27_0       (soft-link)
    jupyter_console:    4.1.1-py27_0       (soft-link)
    jupyter_core:       4.1.0-py27_0       (soft-link)
    libdynd:            0.7.2-0            (soft-link)
    libffi:             3.0.13-0           (soft-link)
    libgfortran:        3.0-0              (soft-link)
    libpng:             1.6.17-0           (soft-link)
    libsodium:          1.0.3-0            (soft-link)
    libtiff:            4.0.6-1            (soft-link)
    libxml2:            2.9.2-0            (soft-link)
    libxslt:            1.1.28-0           (soft-link)
    llvmlite:           0.9.0-py27_0       (soft-link)
    locket:             0.2.0-py27_0       (soft-link)
    lxml:               3.6.0-py27_0       (soft-link)
    markupsafe:         0.23-py27_0        (soft-link)
    matplotlib:         1.5.1-np110py27_0  (soft-link)
    mistune:            0.7.2-py27_0       (soft-link)
    mkl:                11.3.1-0           (soft-link)
    mkl-service:        1.1.2-py27_0       (soft-link)
    mpmath:             0.19-py27_0        (soft-link)
    multipledispatch:   0.4.8-py27_0       (soft-link)
    nbconvert:          4.1.0-py27_0       (soft-link)
    nbformat:           4.0.1-py27_0       (soft-link)
    networkx:           1.11-py27_0        (soft-link)
    nltk:               3.2-py27_0         (soft-link)
    nose:               1.3.7-py27_0       (soft-link)
    notebook:           4.1.0-py27_1       (soft-link)
    numba:              0.24.0-np110py27_0 (soft-link)
    numexpr:            2.5-np110py27_0    (soft-link)
    numpy:              1.10.4-py27_1      (soft-link)
    odo:                0.4.2-py27_0       (soft-link)
    openpyxl:           2.3.2-py27_0       (soft-link)
    openssl:            1.0.2g-0           (soft-link)
    pandas:             0.18.0-np110py27_0 (soft-link)
    partd:              0.3.2-py27_1       (soft-link)
    patchelf:           0.8-0              (soft-link)
    path.py:            8.1.2-py27_1       (soft-link)
    patsy:              0.4.0-np110py27_0  (soft-link)
    pep8:               1.7.0-py27_0       (soft-link)
    pexpect:            4.0.1-py27_0       (soft-link)
    pickleshare:        0.5-py27_0         (soft-link)
    pillow:             3.1.1-py27_0       (soft-link)
    pip:                8.1.1-py27_1       (soft-link)
    pixman:             0.32.6-0           (soft-link)
    ply:                3.8-py27_0         (soft-link)
    psutil:             4.1.0-py27_0       (soft-link)
    ptyprocess:         0.5-py27_0         (soft-link)
    py:                 1.4.31-py27_0      (soft-link)
    pyasn1:             0.1.9-py27_0       (soft-link)
    pycairo:            1.10.0-py27_0      (soft-link)
    pycosat:            0.6.1-py27_0       (soft-link)
    pycparser:          2.14-py27_0        (soft-link)
    pycrypto:           2.6.1-py27_0       (soft-link)
    pycurl:             7.19.5.3-py27_0    (soft-link)
    pyflakes:           1.1.0-py27_0       (soft-link)
    pygments:           2.1.1-py27_0       (soft-link)
    pyopenssl:          0.15.1-py27_2      (soft-link)
    pyparsing:          2.0.3-py27_0       (soft-link)
    pyqt:               4.11.4-py27_1      (soft-link)
    pytables:           3.2.2-np110py27_1  (soft-link)
    pytest:             2.8.5-py27_0       (soft-link)
    python:             2.7.11-0           (soft-link)
    python-dateutil:    2.5.1-py27_0       (soft-link)
    pytz:               2016.2-py27_0      (soft-link)
    pyyaml:             3.11-py27_1        (soft-link)
    pyzmq:              15.2.0-py27_0      (soft-link)
    qt:                 4.8.7-1            (soft-link)
    qtawesome:          0.3.2-py27_0       (soft-link)
    qtconsole:          4.2.0-py27_0       (soft-link)
    qtpy:               1.0-py27_0         (soft-link)
    readline:           6.2-2              (soft-link)
    redis:              2.6.9-0            (soft-link)
    redis-py:           2.10.3-py27_0      (soft-link)
    requests:           2.9.1-py27_0       (soft-link)
    rope:               0.9.4-py27_1       (soft-link)
    scikit-image:       0.12.3-np110py27_0 (soft-link)
    scikit-learn:       0.17.1-np110py27_0 (soft-link)
    scipy:              0.17.0-np110py27_2 (soft-link)
    setuptools:         20.3-py27_0        (soft-link)
    simplegeneric:      0.8.1-py27_0       (soft-link)
    singledispatch:     3.4.0.3-py27_0     (soft-link)
    sip:                4.16.9-py27_0      (soft-link)
    six:                1.10.0-py27_0      (soft-link)
    snowballstemmer:    1.2.1-py27_0       (soft-link)
    sockjs-tornado:     1.0.1-py27_0       (soft-link)
    sphinx:             1.3.5-py27_0       (soft-link)
    sphinx_rtd_theme:   0.1.9-py27_0       (soft-link)
    spyder:             2.3.8-py27_1       (soft-link)
    sqlalchemy:         1.0.12-py27_0      (soft-link)
    sqlite:             3.9.2-0            (soft-link)
    ssl_match_hostname: 3.4.0.2-py27_0     (soft-link)
    statsmodels:        0.6.1-np110py27_0  (soft-link)
    sympy:              1.0-py27_0         (soft-link)
    terminado:          0.5-py27_1         (soft-link)
    tk:                 8.5.18-0           (soft-link)
    toolz:              0.7.4-py27_0       (soft-link)
    tornado:            4.3-py27_0         (soft-link)
    traitlets:          4.2.1-py27_0       (soft-link)
    unicodecsv:         0.14.1-py27_0      (soft-link)
    util-linux:         2.21-0             (soft-link)
    werkzeug:           0.11.4-py27_0      (soft-link)
    wheel:              0.29.0-py27_0      (soft-link)
    xlrd:               0.9.4-py27_0       (soft-link)
    xlsxwriter:         0.8.4-py27_0       (soft-link)
    xlwt:               1.0.0-py27_0       (soft-link)
    xz:                 5.0.5-1            (soft-link)
    yaml:               0.1.6-0            (soft-link)
    zeromq:             4.1.3-0            (soft-link)
    zlib:               1.2.8-0            (soft-link)

Proceed ([y]/n)? y

Linking packages ...
[      COMPLETE      ]|############################################################################################| 100%
#
# To activate this environment, use:
# $ source activate jupyter
#
# To deactivate this environment, use:
# $ source deactivate
#

So this successfully created a new environment, but then when I went to activate it:

demo@ip-172-31-55-246:~$ source activate jupyter
discarding /opt/cloudera/parcels/Anaconda/bin from PATH
Traceback (most recent call last):
  File "/opt/cloudera/parcels/Anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main
Traceback (most recent call last):
  File "/opt/cloudera/parcels/Anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main

Nutty! So then I tried to investigate further:

demo@ip-172-31-55-246:~$ conda info
conda: command not found

demo@ip-172-31-55-246:~$ echo $PATH
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

It's like activate borks out somehow or somewhere. Check it:

demo@ip-172-31-55-246:~$ export PATH=/opt/cloudera/parcels/Anaconda/bin:$PATH

demo@ip-172-31-55-246:~$ conda -V
conda 4.0.5

demo@ip-172-31-55-246:~$ source activate jupyter
discarding /opt/cloudera/parcels/Anaconda/bin from PATH
Traceback (most recent call last):
  File "/opt/cloudera/parcels/Anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main
Traceback (most recent call last):
  File "/opt/cloudera/parcels/Anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main

demo@ip-172-31-55-246:~$ echo $PATH
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

@kalefranz is this resolved by 4.0.6?

@ijstokes
Copy link

A little bit more investigating:

demo@ip-172-31-55-246:~$ export PATH=~/.conda/envs/jupyter/bin:$PATH

demo@ip-172-31-55-246:~$ conda -V
Traceback (most recent call last):
  File "/home/demo/.conda/envs/jupyter/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main

demo@ip-172-31-55-246:~$ which conda
/home/demo/.conda/envs/jupyter/bin/conda

@ijstokes
Copy link

Even tried using --copy to create the new environment, and no dice, still get the ImportError:

demo@ip-172-31-55-246:~$ conda create -n anaconda --copy anaconda 
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ....
Solving package specifications: .........

Package plan for installation in environment /home/demo/.conda/envs/anaconda:

The following NEW packages will be INSTALLED:

    alabaster:          0.7.7-py27_0       (copy)
    anaconda:           4.0.0-np110py27_0  (copy)
    anaconda-client:    1.4.0-py27_0       (copy)
    anaconda-navigator: 1.1.0-py27_0       (copy)
    argcomplete:        1.0.0-py27_1       (copy)
    astropy:            1.1.2-np110py27_0  (copy)

    ....

    yaml:               0.1.6-0            (copy)
    zeromq:             4.1.3-0            (copy)
    zlib:               1.2.8-0            (copy)

Proceed ([y]/n)? y

Linking packages ...
[      COMPLETE      ]|################################################################################################| 100%
#
# To activate this environment, use:
# $ source activate anaconda
#
# To deactivate this environment, use:
# $ source deactivate
#

demo@ip-172-31-55-246:~$ source activate anaconda
discarding /opt/cloudera/parcels/Anaconda/bin from PATH
Traceback (most recent call last):
  File "/opt/cloudera/parcels/Anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main
Traceback (most recent call last):
  File "/opt/cloudera/parcels/Anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main

@kalefranz kalefranz added the type::bug describes erroneous operation, use severity::* to classify the type label May 13, 2016
@kalefranz kalefranz added this to the 4.1 milestone May 13, 2016
@tanweihou
Copy link
Author

tanweihou commented May 16, 2016

@ijstokes
Hi, I could not fix it using the method described in #1733
In the end I recreated another conda env after installing a new anaconda

Regarding errors you posted above, I was unable to reproduce using conda version 4.0.5
It worked without any problems
I guess it's a good sign that I did not mess up again :P

@kalefranz kalefranz added source::community catch-all for issues filed by community members and removed type::bug describes erroneous operation, use severity::* to classify the type labels May 17, 2016
@kalefranz
Copy link
Contributor

@ijstokes Believe it or not, a fix to some of this stuff with conda crippling itself actually touches on some of the configuration issues we've been discussing. There's a configuration ticket marked for the 4.3 milestone, but it'll probably end up being part of 4.2.

@powtac
Copy link

powtac commented Sep 30, 2016

This might occur when the user name in the path on windows contains a space character.

@RyanCCollins
Copy link

Setting the PATH as noted in this stack overflow post resolved this issue for me.

@jurgispods
Copy link

jurgispods commented May 30, 2017

@ijstokes Were you able to find a workaroung for the issue under Cloudera? I am having the same problem with the Anaconda CDH 4.1.1 parcel (although conda -V reports version 4.1.6).

@brechtm
Copy link

brechtm commented Jun 27, 2017

I believe this is due to the fact that Anaconda's python is no longer in PATH. The /usr/bin/env python after the shebang in the conda script then uses the system Python interpreter, which of course doesn't find the conda module.

@jinyangustc
Copy link

My colleague encountered the same error today. It turns out that it is caused by an empty file named site.py. We can just reproduce the bug by touch site.py anywhere on his machine.

However, I cannot reproduce the problem on my box. Even if I upgrade to 4.3.24. But I use pyenv and he doesn't.

@xelmirage
Copy link

Guys, I recently encountered this problem and I found why

My original anaconda installation is anaconda 3 with python3.6. And I configure the conda source to a mirror close to me. Recently I installed a new package to the base environment. The conda command promoted that python3.7 along with other packages will be downloaded and installed.
After that, the python3.6 was replaced by python3.7 and the base environment was corrupted. Like we saw,
"ModuleNotFoundError: No module named 'conda' "
I copied a clean anaconda installation to the original anaconda installation's path, the anaconda installation was repaired. After installing the pack I needed to a new environment, I noticed that the packages are all from conda-forge, not conda/main for conda/free.

Then I realized the conflict may come from a different source, when setting the source of conda, conda-forge was moved to the top and has higher priority that the main conda channel. Then the python3.7 and other packages are from conda-forge and may have a conflict with existing packages.
Then I reordered the conda sources and moved the conda/main and conda/free are on the top. After that, the replacement from python3.6 to python3.7 was performed succesfully in the base enviroment.

Hope this will help

@philthefeel
Copy link

Guys, I recently encountered this problem and I found why

My original anaconda installation is anaconda 3 with python3.6. And I configure the conda source to a mirror close to me. Recently I installed a new package to the base environment. The conda command promoted that python3.7 along with other packages will be downloaded and installed.
After that, the python3.6 was replaced by python3.7 and the base environment was corrupted. Like we saw,
"ModuleNotFoundError: No module named 'conda' "
I copied a clean anaconda installation to the original anaconda installation's path, the anaconda installation was repaired. After installing the pack I needed to a new environment, I noticed that the packages are all from conda-forge, not conda/main for conda/free.

Then I realized the conflict may come from a different source, when setting the source of conda, conda-forge was moved to the top and has higher priority that the main conda channel. Then the python3.7 and other packages are from conda-forge and may have a conflict with existing packages.
Then I reordered the conda sources and moved the conda/main and conda/free are on the top. After that, the replacement from python3.6 to python3.7 was performed succesfully in the base enviroment.

Hope this will help

Thanks for your answer!

Could you show us an explicit example of you've done?. I've got the same problem I'm really lost to solve it just reading all answers

Thanks in advance!

@lucianosilvi
Copy link

Guys, I recently encountered this problem and I found why
My original anaconda installation is anaconda 3 with python3.6. And I configure the conda source to a mirror close to me. Recently I installed a new package to the base environment. The conda command promoted that python3.7 along with other packages will be downloaded and installed.
After that, the python3.6 was replaced by python3.7 and the base environment was corrupted. Like we saw,
"ModuleNotFoundError: No module named 'conda' "
I copied a clean anaconda installation to the original anaconda installation's path, the anaconda installation was repaired. After installing the pack I needed to a new environment, I noticed that the packages are all from conda-forge, not conda/main for conda/free.
Then I realized the conflict may come from a different source, when setting the source of conda, conda-forge was moved to the top and has higher priority that the main conda channel. Then the python3.7 and other packages are from conda-forge and may have a conflict with existing packages.
Then I reordered the conda sources and moved the conda/main and conda/free are on the top. After that, the replacement from python3.6 to python3.7 was performed succesfully in the base enviroment.
Hope this will help

Thanks for your answer!

Could you show us an explicit example of you've done?. I've got the same problem I'm really lost to solve it just reading all answers

Thanks in advance!

Hi @felio333
I had the same issue, and I've done this:

  • Renamed my current miniconda3 folder to miniconda3.old
  • Download Miniconda installer from https://docs.conda.io/en/latest/miniconda.html
  • Run the installer with default options
  • Mix the new miniconda3 folder with the old one, replacing all files when needed
  • Delete the miniconda3 folder from new installation and rename again the miniconda3.old to miniconda3
  • Start a new console to impact bashrc changes
  • Use conda as before.

After that I had some issues like reinstalling some packages in the environment I use, but conda works fine

@zysNLP
Copy link

zysNLP commented Oct 15, 2019

Guys, I recently encountered this problem and I found why
My original anaconda installation is anaconda 3 with python3.6. And I configure the conda source to a mirror close to me. Recently I installed a new package to the base environment. The conda command promoted that python3.7 along with other packages will be downloaded and installed.
After that, the python3.6 was replaced by python3.7 and the base environment was corrupted. Like we saw,
"ModuleNotFoundError: No module named 'conda' "
I copied a clean anaconda installation to the original anaconda installation's path, the anaconda installation was repaired. After installing the pack I needed to a new environment, I noticed that the packages are all from conda-forge, not conda/main for conda/free.
Then I realized the conflict may come from a different source, when setting the source of conda, conda-forge was moved to the top and has higher priority that the main conda channel. Then the python3.7 and other packages are from conda-forge and may have a conflict with existing packages.
Then I reordered the conda sources and moved the conda/main and conda/free are on the top. After that, the replacement from python3.6 to python3.7 was performed succesfully in the base enviroment.
Hope this will help

Thanks for your answer!
Could you show us an explicit example of you've done?. I've got the same problem I'm really lost to solve it just reading all answers
Thanks in advance!

Hi @felio333
I had the same issue, and I've done this:

  • Renamed my current miniconda3 folder to miniconda3.old
  • Download Miniconda installer from https://docs.conda.io/en/latest/miniconda.html
  • Run the installer with default options
  • Mix the new miniconda3 folder with the old one, replacing all files when needed
  • Delete the miniconda3 folder from new installation and rename again the miniconda3.old to miniconda3
  • Start a new console to impact bashrc changes
  • Use conda as before.

After that I had some issues like reinstalling some packages in the environment I use, but conda works fine

Seem still not clear, since I have many envs before. When reinstall a new conda, only move these envs enough? "replacing all files when needed" you said not means move any one of condas? Thank but I move envs only works, but pkgs in base yes still empty and this is a small question.
So I change your advices as:
--Renamed my current anaconda3 folder to anaconda3.old
--Download anaconda installer from you old conda.sh as Anaconda3-5.2.0-Linux-x86_64.sh
--Run the installer with default options
--Replacing envs from old to new.
--Delete old.
--Start a new console to impact bashrc changes.(when reinstall it should have done, not necessary)
--Take no thank.

@zysNLP
Copy link

zysNLP commented Oct 15, 2019

Finally, since this problem was discovered when I reinstalled the spyder, it is still impossible to reinstall the spyder in env "base" even after the above work. I have not solved this problem, so I input conda install spyder again in "base" and found that python3.7 will be installed again, so I gave up.

@KraFusion
Copy link

for the Cloudera folks....

changing the shebang in /opt/cloudera/parcels/Anaconda/bin/conda
from
#!/usr/bin/env python
to
#!/opt/cloudera/parcels/Anaconda/bin/python

worked for me

@AmmarOkran
Copy link

Just update conda to compatible with python works for me

@jhji-soochow
Copy link

Guys, I recently encountered this problem and I found why
My original anaconda installation is anaconda 3 with python3.6. And I configure the conda source to a mirror close to me. Recently I installed a new package to the base environment. The conda command promoted that python3.7 along with other packages will be downloaded and installed.
After that, the python3.6 was replaced by python3.7 and the base environment was corrupted. Like we saw,
"ModuleNotFoundError: No module named 'conda' "
I copied a clean anaconda installation to the original anaconda installation's path, the anaconda installation was repaired. After installing the pack I needed to a new environment, I noticed that the packages are all from conda-forge, not conda/main for conda/free.
Then I realized the conflict may come from a different source, when setting the source of conda, conda-forge was moved to the top and has higher priority that the main conda channel. Then the python3.7 and other packages are from conda-forge and may have a conflict with existing packages.
Then I reordered the conda sources and moved the conda/main and conda/free are on the top. After that, the replacement from python3.6 to python3.7 was performed succesfully in the base enviroment.
Hope this will help

Thanks for your answer!
Could you show us an explicit example of you've done?. I've got the same problem I'm really lost to solve it just reading all answers
Thanks in advance!

Hi @felio333
I had the same issue, and I've done this:

  • Renamed my current miniconda3 folder to miniconda3.old
  • Download Miniconda installer from https://docs.conda.io/en/latest/miniconda.html
  • Run the installer with default options
  • Mix the new miniconda3 folder with the old one, replacing all files when needed
  • Delete the miniconda3 folder from new installation and rename again the miniconda3.old to miniconda3
  • Start a new console to impact bashrc changes
  • Use conda as before.

After that I had some issues like reinstalling some packages in the environment I use, but conda works fine

Seem still not clear, since I have many envs before. When reinstall a new conda, only move these envs enough? "replacing all files when needed" you said not means move any one of condas? Thank but I move envs only works, but pkgs in base yes still empty and this is a small question.
So I change your advices as:
--Renamed my current anaconda3 folder to anaconda3.old
--Download anaconda installer from you old conda.sh as Anaconda3-5.2.0-Linux-x86_64.sh
--Run the installer with default options
--Replacing envs from old to new.
--Delete old.
--Start a new console to impact bashrc changes.(when reinstall it should have done, not necessary)
--Take no thank.

this works for me, thank you.

@Armughan-Shahid-AAI
Copy link

I tried all the steps above but couldnt resolve the issue. However this worked for me .

@Velcon-Zheng
Copy link

Hi all, I encountered problem with conda after I updated packages
After executing conda update --all, I freed up some spaces with conda clean -pity
It is similar to issue #2200

username@userpc:~> conda
Traceback (most recent call last):
  File "/username/anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main
username@userpc:~> conda list
Traceback (most recent call last):
  File "/username/anaconda/bin/conda", line 4, in <module>
    from conda.cli.main import main
ImportError: No module named conda.cli.main
username@userpc:~> . activate myenv
bash: activate: No such file or directory
username@userpc:~> which activate
which: no activate in ($PATH)
username@userpc:~> 

I checked the root environment directory and found that some symbolic link files are broken, eg. activate, deactivate
Those files are pointed to conda .pkgs directory, which was cleaned with conda clean -pity
Any ideas how to recover it, or reinstall conda ?

It could be a conflict between Python in Conda with system Python, or between multiple conda.

First, you can check the $PATH, $PYTHONPATH, $PYTHONHOME, $LD_LIBRARY_PATH, and $LIBRARY_PATH in <your home>/.bashrc file to make sure there is only one python and python library from conda directory.

There maybe the other similar file to .bashrc file in your systerm.
If you do not set $PATH, $PYTHONPATH, $PYTHONHOME, $LD_LIBRARY_PATH, or $LIBRARY_PATH in the begining, it is OK.

Second, add <your conda>/bin to the $PATH.

Third, restart the system or re-enter your server.

Maybe source <your home>/.bashrc is OK, but in my server it is OK for re-entering the server.

Finally, try conda --help.

It resolves the problem.

@M-kadi
Copy link

M-kadi commented Sep 26, 2020

On Windows : go to "System Properties" -> "Environment Variables" -> clear value of "PYTHONPATH"

@duhd1993
Copy link

duhd1993 commented Dec 9, 2020

https://stackoverflow.com/questions/54546450/how-does-using-conda-to-install-a-package-change-my-python-version-and-remove-co/54563455#54563455

I think this answer should be considered in Anaconda. You will inevitably break your conda when you upgrade anaconda and some package triggers a python version change.

@github-actions
Copy link

Hi there, thank you for your contribution to Conda!

This issue has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Dec 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity source::community catch-all for issues filed by community members
Projects
None yet
Development

No branches or pull requests