Difference between revisions of "Python venv"
Jump to navigation
Jump to search
| (2 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
| − | Establish a new virtual environment | + | ===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 [https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment virtual environments] with Conda | ||
| + | * | ||
| + | |||
| + | |||
| + | |||
| + | ===Establish a new virtual environment=== | ||
python -m venv venv | python -m venv venv | ||
Next, activate it: | Next, activate it: | ||
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
- Managing virtual environments with Conda
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