linuxanaconda3mne-python

After a failed installation of MNE-Python, Linux is unable to start the conda virtual environment.The complete error message I received is as follows


Xshell 7 (Build 0141)
Copyright (c) 2020 NetSarang Computer, Inc. All rights reserved.

Type `help' to learn how to use Xshell prompt.
[C:\~]$ 

Connecting to 192.168.1.73:999...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.15.0-142-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

236 packages can be updated.
5 updates are security updates.

New release '18.04.6 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Wed Jan 17 15:32:21 2024 from 192.168.1.28
p: command not found

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/exceptions.py", line 1129, in __call__
        return func(*args, **kwargs)
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/cli/main.py", line 111, in main_sourced
        print(activator.execute(), end="")
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 167, in execute
        return getattr(self, self.command)()
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 141, in activate
        builder_result = self.build_activate(self.env_name_or_prefix)
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 288, in build_activate
        return self._build_activate_stack(env_name_or_prefix, False)
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 316, in _build_activate_stack
        conda_prompt_modifier = self._prompt_modifier(prefix, conda_default_env)
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 649, in _prompt_modifier
        return context.env_prompt.format(
    KeyError: 'mne'

`$ /home/lqj2/anaconda3/bin/conda shell.posix activate base`

  environment variables:
                 CIO_TEST=<not set>
                CONDA_EXE=/home/lqj2/anaconda3/bin/conda
         CONDA_PYTHON_EXE=/home/lqj2/anaconda3/bin/python
               CONDA_ROOT=/home/lqj2/anaconda3
              CONDA_SHLVL=0
           CURL_CA_BUNDLE=<not set>
                     PATH=/home/lqj2/anaconda3/condabin:/bin:/usr/bin:/usr/local/bin:/usr/local/
                          cuda/bin:/sbin:/sbin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
            shell level : 0
       user config file : /home/lqj2/.condarc
 populated config files : /home/lqj2/.condarc
          conda version : 22.9.0
    conda-build version : 3.22.0
         python version : 3.9.13.final.0
       virtual packages : __cuda=11.1=0
                          __linux=4.15.0=0
                          __glibc=2.23=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/lqj2/anaconda3  (writable)
      conda av data dir : /home/lqj2/anaconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/lqj2/anaconda3/pkgs
                          /home/lqj2/.conda/pkgs
       envs directories : /home/lqj2/anaconda3/envs
                          /home/lqj2/.conda/envs
               platform : linux-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.13 Linux/4.15.0-142-generic ubuntu/16.04.2 glibc/2.23
                UID:GID : 1035:1035
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.



No report sent. To permanently opt-out, use

    $ conda config --set report_errors false



# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/exceptions.py", line 1129, in __call__
        return func(*args, **kwargs)
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/cli/main.py", line 111, in main_sourced
        print(activator.execute(), end="")
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 167, in execute
        return getattr(self, self.command)()
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 141, in activate
        builder_result = self.build_activate(self.env_name_or_prefix)
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 288, in build_activate
        return self._build_activate_stack(env_name_or_prefix, False)
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 316, in _build_activate_stack
        conda_prompt_modifier = self._prompt_modifier(prefix, conda_default_env)
      File "/home/lqj2/anaconda3/lib/python3.9/site-packages/conda/activate.py", line 649, in _prompt_modifier
        return context.env_prompt.format(
    KeyError: 'mne'

`$ /home/lqj2/anaconda3/bin/conda shell.posix activate base`

  environment variables:
                 CIO_TEST=<not set>
                CONDA_EXE=/home/lqj2/anaconda3/bin/conda
         CONDA_PYTHON_EXE=/home/lqj2/anaconda3/bin/python
               CONDA_ROOT=/home/lqj2/anaconda3
              CONDA_SHLVL=0
           CURL_CA_BUNDLE=<not set>
                     PATH=/home/lqj2/anaconda3/condabin:/bin:/usr/bin:/usr/local/bin:/usr/local/
                          cuda/bin:/sbin:/sbin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
            shell level : 0
       user config file : /home/lqj2/.condarc
 populated config files : /home/lqj2/.condarc
          conda version : 22.9.0
    conda-build version : 3.22.0
         python version : 3.9.13.final.0
       virtual packages : __cuda=11.1=0
                          __linux=4.15.0=0
                          __glibc=2.23=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/lqj2/anaconda3  (writable)
      conda av data dir : /home/lqj2/anaconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/lqj2/anaconda3/pkgs
                          /home/lqj2/.conda/pkgs
       envs directories : /home/lqj2/anaconda3/envs
                          /home/lqj2/.conda/envs
               platform : linux-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.13 Linux/4.15.0-142-generic ubuntu/16.04.2 glibc/2.23
                UID:GID : 1035:1035
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.


No report sent. To permanently opt-out, use

    $ conda config --set report_errors false

Above content is the Linux error message. How can I fix it?

Next, I will provide a detailed process of how this situation occurred.

At first, I wanted to install the MNE-Python through the file download from its website according to the code sh ./MNE-Python-1.6.0_0-Linux.sh. However, when the installation programe asked me that Do you wish the installer to initialize MNE-Python by running conda init?,I choosed yes. This action leads to the MNE-Python will be activated in every conda virtual environment. So I tried many methods to cancel this initialization action. One of them may be effective is conda rename --name=mne old_mne # rename existing "mne" env to "old_mne". After that, my base environment could not be activated normally and sent me the above error messages.


Solution

  • Solving this problem by asking ChatGPT.
    Firstly, nano /home/lqj2/.condarc
    Changing the environment default_env
    Ctrl+X to save and Enter to confirm.