Distro: Debian 11
Python: 3.9.2
Shell: Bash
I'm attempting to permanently update a user's path using Python. I want to essentially do the equivalent of this using Python:
export PATH="$PATH:/usr/local/bin/folderA"
export PATH="$PATH:$HOME/.local/share/folderB/bin"
echo export PATH="$PATH:$HOME/.local/bin" >> "$HOME"/.bashrc
In Python I attempted:
import os
from pathlib import Path
dir_home = str(Path.home())
os.system('export PATH=$PATH:/usr/local/bin/folderA')
os.system('export PATH=$PATH:' + dir_home + '/.local/share/folderB/bin')
os.system('echo export PATH=$PATH:' + dir_home + '/.local/bin >>' + dir_home + '/.bashrc')
The echo export PATH="$PATH:$HOME/.local/bin" >> "$HOME"/.bashrc
works but the other two lines don't get input into the $PATH.
I don't care how it gets done though. I am using this method as I thought it was the way to do it.
Thanks