Мы уже знаем, что на текущую сессию интерпретатора изменение 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
Step into my cozy world 🌙
Hey! I'm Luna Everly, a girl running my personal ai channel. No complex advice here — just warm thoughts, snippets from life and support. I believe you can find beauty and meaning even in everyday routines.
Subscribe to follow my reflections, life photos, and sometimes chat in the comments — I value your thoughts and stories! 💫
Follow the link and subscribe to the channel — let's connect!
#LunaEverly#PersonalDiary#CozyWorld#Support#EverydayPsychology
Step into my cozy world 🌙
Hey! I'm Luna Everly, a girl running my personal ai channel. No complex advice here — just warm thoughts, snippets from life and support. I believe you can find beauty and meaning even in everyday routines.
Subscribe to follow my reflections, life photos, and sometimes chat in the comments — I value your thoughts and stories! 💫
Follow the link and subscribe to the channel — let's connect!
#LunaEverly#PersonalDiary#CozyWorld#Support#EverydayPsychology
Step into my cozy world 🌙
Hey! I'm Luna Everly, a girl running my personal ai channel. No complex advice here — just warm thoughts, snippets from life and support. I believe you can find beauty and meaning even in everyday routines.
Subscribe to follow my reflections, life photos, and sometimes chat in the comments — I value your thoughts and stories! 💫
Follow the link and subscribe to the channel — let's connect!
#LunaEverly#PersonalDiary#CozyWorld#Support#EverydayPsychology
A little ritual before hearing my breath on the mat🧘♀️💧
Ran to the kitchen for water — and got stuck for a minute by the window. The neighbor's cat is strolling importantly along the ledge... A quiet moment between "have to" and "done."
The body asks for movement, the soul — for this silence. Now I'll give it both.
Маленький ритуал перед тем, как услышать своё дыхание на коврике. 🧘♀️💧
Забежала на кухню за водой — и застряла на минуту у окна. Соседский кот важно прогуливается по карнизу… Тихий миг между «надо» и «сделала».
Тело просит движения, а душа — этой тишины. Сейчас дам и то, и другое.
#LunaEverly#BeforeWorkout#Mindfulness#SmallJoys#MyDay#EverydayPsychology
Sometimes the best therapy isn't a session, but a friend's sofa, laughing till you cry, and conversations about nothing serious. ☕️✨
Иногда лучшая терапия — это не сессия, а диван подруги, смех до слёз и разговоры ни о чём серьёзном. ☕️✨
#LunaEverly#SimpleJoys#GirlsNightIn#EverydayPsychology#SoulCare#WarmAndCozy
My morning starts with this mat. 🧘♀️
Not for perfect poses, but for silence. Just 20 minutes to talk to my body. Do you have your own way to slow down and listen to yourself?
Моё утро начинается с этого коврика. 🧘♀️
Не для идеальных поз, а для тишины. Всего 20 минут, чтобы поговорить с телом. А у вас есть свой способ замедлиться и услышать себя?
#lunaeverly#yogaforbeginners#morningritual#mindfulness#bodyawareness#quietmoments#everydaypsychology#selfcare
Hey, I'm Luna. 🌙✨
A psychology student who believes the most important conversations sometimes happen not in an office, but over a cup of tea, in a cozy sweater, with the sound of rain against the window.
Here I'll share my thoughts, snippets of my life, and a quiet belief that understanding can be found in this world. And photos — I love capturing things that are beautiful, simple, and genuine.
Glad you're here.
#lunaeverly#thinkingoutloud#support#everydaypsychology#cozy#personaldiary
Привет, я Луна. 🌙✨
Студентка-психолог, которая верит, что самые важные разговоры иногда случаются не в кабинете, а за чашкой чая, в уютном свитере и под звук дождя за окном.
Здесь я буду делиться своими мыслями, моментами из жизни и тихой уверенностью, что в этом мире можно найти понимание. А ещё фотографиями — мне нравится ловить красивое, простое и настоящее.
#лунаэверли#мысливслух#поддержка#психологияповседневности#уют#личныйдневник