-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10a60da
commit 1161321
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: Running Python Source With The Fish Shell | ||
status: 'Blog' | ||
description: 'A quick and simple way to activate your python venv while using the fish shell' | ||
readTime: '2min' | ||
date: 'October 24th, 2024' | ||
tags: ['Shell', 'Python'] | ||
--- | ||
|
||
Let me guess, you ran | ||
``` | ||
python -m venv .venv | ||
``` | ||
and then | ||
``` | ||
source .venv/bin/activate | ||
``` | ||
to use your newly created enviroment and got this: | ||
|
||
```bash | ||
.venv/bin/activate (line 48): Unsupported use of '='. In fish, please use 'set _OLD_VIRTUAL_PATH "$PATH"'. | ||
_OLD_VIRTUAL_PATH="$PATH" | ||
^~~~~~~~~~~~~~~~~~~~~~~~^ | ||
from sourcing file .venv/bin/activate | ||
source: Error while reading file '.venv/bin/activate' | ||
``` | ||
Well there's a pretty easy solution for that! Thing is, there's multiple activate scripts within the _/bin/_ folder on your virtual enviroment. | ||
```bash | ||
ls .venv/bin/ | ||
Activate.ps1 activate.csh pip* pip3.12* python3@ | ||
activate activate.fish pip3* python@ python3.12@ | ||
``` | ||
There it is! An activate script wrriten in fish. So while in fish just use that. | ||
```bash | ||
source .venv/bin/activate.fish | ||
``` | ||
However, there is even a better way we can activate the virtual enviroment. By adding an _alias_. | ||
```bash | ||
alias -s myvenv="source $HOME/.venv/venvname/bin/activate.fish" | ||
``` |