Cannot activate conda default 'base' environment

Hello, I installed conda using sudo dnf install conda. I closed my shell and even restarted my system. I also tried conda init, conda activate and conda activate base and restarting again. When I launch my shell I get (base) wiking@walhalla:~$ .

However, when I try conda install numpy I get this error message:

usr/lib/python3.13/site-packages/conda/gateways/logging.py:66: FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in staticmethod() if you want to preserve the old behavior
  record.msg = self.TOKEN_REPLACE(record.msg)

NoBaseEnvironmentError: This conda installation has no default base environment. Use
'conda create' to create new environments and 'conda activate' to
activate environments.

If I do conda env list I get

(base) wiking@walhalla:~$ conda env list
# conda environments:
#
base                  *  /usr

Maybe something is wrong with the path; /usr doesn’t look like a good place to store anything.

This shows a command you did not include in the above post.

If I do conda create -n base is it okay that it wants to create the base environment at /usr? This seems like an odd place to put it. Should I proceed with that or put it somewhere else?

Put it somewhere else. You’ll have nothing but problems if you try to install things under /usr with a package manager other than RPM.

Like where should I put it?

Anywhere else would be better. If it is just to be used by your account, something like ~/envs would probably be fine. If you expect multiple users to share an environment, you might want to put it somewhere like /opt/conda-v24.

It looks like there is some documentation for setting up environments for conda here:

https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#specifying-a-location-for-an-environment

Did I abort this in time? I nearly created the environment in /usr before I checked with y’all first:

(base) wiking@walhalla:~$ conda create -n base
WARNING: A directory already exists at the target location '/usr'
but it is not a conda environment.
Continue creating environment (y/[n])? y

Channels:
 - conda-forge
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /usr



Proceed ([y]/n)? n

/usr/lib/python3.13/site-packages/conda/gateways/logging.py:66: FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in staticmethod() if you want to preserve the old behavior
  record.msg = self.TOKEN_REPLACE(record.msg)

CondaSystemExit: Exiting.

I wouldn’t expect that to be able to overwrite any system files if you were running it as a normal user.

You might try something like rpm -qa | grep '^conda' | xargs rpm -V to see if it shows any modified system packages (no news is good news). If you do see that some files under /usr have been modified, use rpm -qf <path-to-file> to find out which package the file belongs to and then reinstall the package with dnf reinstall <package-name>.

HTH

(base) wiking@walhalla:~$ rpm -qa | grep '^conda' | xargs rpm -V
S.5....T.    /usr/bin/conda
S.5....T.    /usr/bin/conda-env
(base) wiking@walhalla:~$ cd /usr/bin/conda-env
bash: cd: /usr/bin/conda-env: Not a directory
(base) wiking@walhalla:~$ ls /usr/bin/conda-env
/usr/bin/conda-env
(base) wiking@walhalla:~$ ls /usr/bin/conda-env/
ls: cannot access '/usr/bin/conda-env/': Not a directory

Yes, those are files that have been overwritten, not directories. Use rpm -qf /usr/bin/conda and rpm -qf /usr/bin/conda-env to find out what packages they belong to and then use sudo dnf reinstall <pacakge-name> to replace them with the correct system versions. Then you can re-run that rpm -qa | grep '^conda' | xargs rpm -V command to verify that all the files are back to normal.

(base) wiking@walhalla:~$ rpm -qf /usr/bin/conda
conda-24.9.1-2.fc41.noarch
(base) wiking@walhalla:~$ rpm -qf /usr/bin/conda-env
conda-24.9.1-2.fc41.noarch
(base) wiking@walhalla:~$ sudo dnf reinstall conda-24.9.1-2.fc41.noarch
Place your right index finger on the fingerprint reader
Updating and loading repositories:
 Mullvad VPN                                                                                                          100% | 797.0   B/s |   3.0 KiB |  00m04s
 SoftMaker Software GmbH                                                                                              100% |   1.4 KiB/s |   1.3 KiB |  00m01s
 RPM Fusion for Fedora 41 - Nonfree - Steam                                                                           100% |   7.5 KiB/s |   6.2 KiB |  00m01s
 Dropbox Repository                                                                                                   100% |   3.8 KiB/s |   1.5 KiB |  00m00s
 RPM Fusion for Fedora 41 - Nonfree - NVIDIA Driver                                                                   100% |  13.8 KiB/s |   7.1 KiB |  00m01s
 google-chrome                                                                                                        100% |  12.9 KiB/s |   1.3 KiB |  00m00s
 Copr repo for rstudio owned by iucar                                                                                 100% |   9.4 KiB/s |   2.1 KiB |  00m00s
 RPM Fusion for Fedora 41 - Nonfree - Updates                                                                         100% |  53.7 KiB/s |   6.9 KiB |  00m00s
 Fedora 41 - x86_64 - Updates                                                                                         100% |  69.9 KiB/s |  14.9 KiB |  00m00s
 RPM Fusion for Fedora 41 - Free - Updates                                                                            100% |   7.8 KiB/s |   3.9 KiB |  00m00s
 Copr repo for cran owned by iucar                                                                                    100% |  27.0 KiB/s |   1.5 KiB |  00m00s
 RPM Fusion for Fedora 41 - Nonfree - NVIDIA Driver                                                                   100% |  26.1 KiB/s |  16.2 KiB |  00m01s
 google-chrome                                                                                                        100% |  16.3 KiB/s |   3.2 KiB |  00m00s
 RPM Fusion for Fedora 41 - Nonfree - Updates                                                                         100% |  43.0 KiB/s |  31.5 KiB |  00m01s
 Fedora 41 - x86_64 - Updates                                                                                         100% |   1.7 MiB/s |   2.4 MiB |  00m01s
 RPM Fusion for Fedora 41 - Free - Updates                                                                            100% |  99.6 KiB/s |  45.6 KiB |  00m00s
 Copr repo for cran owned by iucar                                                                                    100% |  24.6 MiB/s |  12.4 MiB |  00m01s
Repositories loaded.
Package                                              Arch         Version                                               Repository                        Size
Reinstalling:
 conda                                               noarch       24.9.1-2.fc41                                         updates                       14.8 KiB
   replacing conda                                   noarch       24.9.1-2.fc41                                         updates                       14.8 KiB

Transaction Summary:
 Reinstalling:       1 package
 Replacing:          1 package

Total size of inbound packages is 16 KiB. Need to download 16 KiB.
After this operation, 0 B extra will be used (install 15 KiB, remove 15 KiB).
Is this ok [y/N]: y
[1/1] conda-0:24.9.1-2.fc41.noarch                                                                                    100% |  43.1 KiB/s |  16.4 KiB |  00m00s
--------------------------------------------------------------------------------------------------------------------------------------------------------------
[1/1] Total                                                                                                           100% |  31.2 KiB/s |  16.4 KiB |  00m01s
Running transaction
[1/4] Verify package files                                                                                            100% | 250.0   B/s |   1.0   B |  00m00s
[2/4] Prepare transaction                                                                                             100% |   7.0   B/s |   2.0   B |  00m00s
[3/4] Reinstalling conda-0:24.9.1-2.fc41.noarch                                                                       100% | 555.2 KiB/s |  16.1 KiB |  00m00s
[4/4] Removing conda-0:24.9.1-2.fc41.noarch                                                                           100% |  24.0   B/s |   9.0   B |  00m00s
Complete!
(base) wiking@walhalla:~$ rpm -qa | grep '^conda' | xargs rpm -V
(base) wiking@walhalla:~$
1 Like

Reading what you gave me, this is what I came up with. What do you think?

cd /opt
sudo mkdir conda-v24
cd conda-v24
sudo mkdir envs
conda create --prefix ./envs -n base

Or should I do

cd /opt
sudo mkdir conda-v24
conda create --prefix ./conda-v24 -n base

I’d go with the second one. I don’t see any reason to make the path any longer than necessary.

Also, you don’t need to pre-create the directory unless you intend to do something fancy with the permissions (e.g. setting a group sticky bit because you have changed the default umask for users to something like 0027 or 0007; with the Fedora Linux default of 0022, however, a group sticky bit should not be needed)

Edit: On second thought, maybe you do need to pre-create the directory just to grant your user account access to it (e.g. sudo chown $USER: /opt/conda-v24). Then you should be able to run the rest of the conda commands as your normal user account and not risk overwriting any system files.

If conda is upgradeed beyond v24 won’t the name conda-v24 no longer make sense? I would assume the environment files would still stay in the same place even if conda itself were upgraded.

So is there any reason not to do this instead?

cd /opt
sudo mkdir conda
sudo chown $USER: /opt/conda
conda create --prefix ./conda -n base

Yeah, that makes sense. It just depends on how you want to manage things. :slightly_smiling_face:

I guess it’s not possible to use the --prefix and --name arguments at the same time. I get this error:

conda create: error: argument -n/--name: not allowed with argument -p/--prefix

How else am I supposed to tell conda that I am creating the default environment, though?

I’m not a conda user, but I think the idea is that your are supposed to run something like the following:

$ cd /opt/conda/bin
$ ./conda init bash

And that is supposed to alter your ~/.bashrc so that your custom conda environment will be found instead of the “base” (system) environment. You could manually move whatever that conda init bash command adds to your ~/.bashrc to a new file under /etc/profile.d if you want those settings applied for all users.

Edit: Some documentation: conda init and conda activate — conda 25.1.1 documentation

So you are saying that I would first do conda create --prefix ./conda and this would create the ./conda/bin folder?

Yes, I think that is how it is supposed to work. I’m not sure though. I dabbled with conda once some time ago, but I haven’t used it since and I don’t remember much about how to set up the environment (other than not to store things under /usr).

Aren’t there other arguments that are needed if I want the environment to have anything installed in it (for example python=3.9 jupyterlab=3.2 matplotlib=3.5 numpy=1.21)?

I guess I can experiment with the default environment and delete it and recreate it if it’s not working for me.

Don’t I need to at least specify the Python version though?