Difference between revisions of "Python venv"

From Bitnami MediaWiki
Jump to navigation Jump to search
 
Line 14: Line 14:
 
  python -m ipykernel install --user --name=myenv
 
  python -m ipykernel install --user --name=myenv
  
−
 
+
* Managing [https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment virtual environments] with Conda
 +
*
  
  

Latest revision as of 18:35, 23 October 2023

Installing Anaconda[edit]

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[edit]

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