Project code can silently run under the wrong interpreter when base and the project environment use different Python releases. Creating the environment with a python= version constraint makes Conda solve the interpreter and its dependency set together before any project packages are installed.
The conda create command accepts package specifications during environment creation. A specification such as python=3.11 asks the solver for a compatible Python 3.11 build from the active channels, creates the environment under Conda's environment directory, and records the installed packages in that environment only.
Channel policy matters before the solver can read package metadata. Anaconda's defaults channels may require Terms of Service acceptance, while a project that uses conda-forge or an internal channel should configure those channels before creating the environment so the first solve uses the intended source.
$ conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main accepted Terms of Service for https://repo.anaconda.com/pkgs/main $ conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r accepted Terms of Service for https://repo.anaconda.com/pkgs/r
Accept channel terms only after reviewing them and confirming that the channel is allowed for the environment. If defaults is not allowed, remove or replace that channel before creating the environment.
$ conda create --name py311-lab python=3.11 --yes
2 channel Terms of Service accepted
Channels:
- defaults
Platform: linux-aarch64
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /opt/conda/envs/py311-lab
added / updated specs:
- python=3.11
The following NEW packages will be INSTALLED:
python pkgs/main/linux-aarch64::python-3.11.15-hdc5b1c3_1
pip pkgs/main/noarch::pip-26.1.1-pyhc872135_1
setuptools pkgs/main/linux-aarch64::setuptools-82.0.1-py311hd43f75c_0
wheel pkgs/main/linux-aarch64::wheel-0.46.3-py311hd43f75c_0
##### snipped #####
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate py311-lab
#
Replace py311-lab with the environment name and python=3.11 with the required minor version. Leave off --yes when the package plan should pause for interactive confirmation.
$ conda env list # conda environments: # # * -> active # + -> frozen base /opt/conda py311-lab /opt/conda/envs/py311-lab
$ conda activate py311-lab (py311-lab) $
If activation is not recognized, initialize Conda for the current shell and reopen the terminal before retrying.
Related: How to initialize Conda for a shell
Related: How to activate a Conda environment
(py311-lab) $ python --version Python 3.11.15
The patch version may be newer than the version shown here. The first two components should match the requested minor release, such as 3.11.
(py311-lab) $ python -c "import sys; print(sys.executable)" /opt/conda/envs/py311-lab/bin/python
The path should point inside the new environment, not inside base or the system Python installation.