Мы уже знаем, что на текущую сессию интерпретатора изменение PYTHONPATH никак не повлияет. Но если вы запустите дочерний процесс, то он унаследует окружение текущего процесса, а значит и изменения в любых переменных будут на него влиять.
Вот небольшой пример:
Объявляем переменную
user@host:~$ export PYTHONPATH=/path1
Запускаем интерпретатор
user@host:~$ python3
Проверим что в sys.path
>>> import sys
>>> print(sys.path)
['', '/path1', '/usr/lib/...', ...]
Добавляем что-то в переменную
>>> import os
>>> os.emviron['PYTHONPATH'] = '/path1:/path2'
>>> print(sys.path)
['', '/path1', '/usr/lib/...', ...]
Изменений нет. Но давайте запустим дочерний процесс и посмотрим там
>>> os.system('python3')
# теперь мы находимся в другом процессе
>>> import sys
>>> print(sys.path)
['', '/path1', '/path2', '/usr/lib/...', ...]
Тоже самое будет и с subprocess, так как по умолчанию текущее окружение тоже наследуется.
>>> import subprocess
>>> subprocess.call(['python3', '-c', 'import sys;print(sys.path)'])
['', '/path1', '/path2', '/usr/lib/...', ...]
______________________
Лучшей практикой является передача энвайронмента явно через аргумент env!
import subprocess
subprocess.call(cmd, env={'PYTHONPATH': '...'})
Это поможет точно понимать какое окружение будет у запускаемого процесса и при этом не изменять окружение текущего процесса.
#basic
According to @/mkgenie, the president of Michael Jackson's Chinese fanclub, and that had access to the list of recording artists of the MJ tribute project in 2023, Jungkook was one of the renowned singers that would get to sing one of the 10 never-released song written by Michael Jackson along with Bruno Mars, Doja Cat and Sza!
#JUNGKOOK
•@OUR_7_PRINCES•
“Yes, Love him! Incredible! His dancing, singing, songs, incredible machine. I love that dude, like he’s incredible”
— Omar Rudberg, a Venezuelan-Swedish singer and actor, about #Jungkook
#JUNGKOOK
•@OUR_7_PRINCES•
Rolling Stone UK Twitter Update
Read the full interview with #JungKook here
https://www.rollingstone.co.uk/music/features/jung-kook-bts-interview-rolling-stone-photos-57298/
-@All_BTS_Updates
GameSpot, a major American website providing news & reviews about video games, wrote an article about #Jungkook
“BTS's Jungkook Is A Streamer Now, Here Are The Games He's Played So Far”
https://www.gamespot.com/gallery/btss-jungkook-is-a-streamer-now-here-are-the-games-hes-played-so-far/2900-7286/
#INFO
•@OUR_7_PRINCES•
Famous actor Manny Jacinto said #Jungkook was his bias in a recent interview for Cosmopolitan
Q: Recently, a photo of you at a j-hope concert made the internet rounds. Who is your BTS bias?
🗣️ “Jungkook. I was a dancer, and I have this theory. Jungkook apparently trained in Los Angeles when he was younger, and I think we almost crossed paths and trained in the same studio around the same time. I mean, he is, like, eight years younger than me, but I saw videos and pictures of him training at the same studio. And I was like, wait, when was this? And this was around the same time, like, summer of 2012, 2011. I think he’s one of the best dancers on the team. But I also just dig his music.”
#INFO
•@OUR_7_PRINCES•