Python venv
Revision as of 18:35, 23 October 2023 by 98.152.106.150 (talk)
Installing Anaconda
It appears ArchLinux no longer supports non-virtual Python environments. So I'm making the plunge.
Do you wish to update your shell profile to automatically initialize conda? This will activate conda on startup and change the command prompt when activated. If you'd prefer that conda's base environment not be activated on startup, run the following command when conda is activated:
conda config --set auto_activate_base false
You can undo this by running `conda init --reverse $SHELL`? [yes|no]
To add a kernel to the default Jupyter lab/notebook:
python -m ipykernel install --user --name=myenv
- Managing virtual environments with Conda
Establish a new virtual environment
python -m venv venv
Next, activate it:
source venv/bin/activate
You should see the new prompt indicating you're inside the virtual environment:
(venv) $
Next install the versions you need of various packages, specifying their version numbers:
pip install numpy==1.22.0
To exit, type:
(venv) $ deactivate
Reference: Python virtual environments: A primer