Difference between revisions of "Python venv"

From Bitnami MediaWiki
Jump to navigation Jump to search
Line 11: Line 11:
 
  You can undo this by running `conda init --reverse $SHELL`? [yes|no]
 
  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
  
  

Revision as of 00:12, 19 October 2023

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



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