Что делать если нужно поставить какую-то Python-библиотеку а root-прав нет? То есть в систему библиотеку никак и ничего не поставить.
Есть как минимум два способа это решить правильно!
🔸 Сделать виртуальное окружение и ставить там что угодно.
Это позволит создать полностью независимое исполняемое окружение для ваших приложений.
Все библиотеки будут храниться в домашней директории юзера а значит доступ на запись имеется.
Создать очень просто:
python3 -m venv ~/venvs/myenvname
Теперь активируем окружение
# Linux
source ~/venvs/myenvname/bin/activate
# Windows
%userprofile%\venvs\myenvname\Scripts\activate.bat
Можно ставить любые библиотеки и запускать приложение.
Это стандартный метод работы с любым проектом. Если еще не используете его, то пора начинать. Даже при наличии root доступа!
🔸 Бывает, что нет возможности запустить приложение из своего виртуального окружения. Например, его запускает какой-то сервис от вашего юзера и вставить активацию окружения вы не можете.
В этом случае можно установить библиотеки для Python не глобально в систему, а только для юзера.
Выполните этот код в консоли:
python3 -m site
Вы получите что-то такое:
sys.path = [
'/home/user',
'/usr/lib/python37.zip',
'/usr/lib/python3.7',
'/usr/lib/python3.7/lib-dynload',
'/home/user/.local/lib/python3.7/site-packages',
...
]
USER_BASE: '/home/user/.local'
USER_SITE: '/home/user/.local/lib/python3.7/site-packages'
ENABLE_USER_SITE: True
Нас интересует параметр USER_SITE. Это путь к пользовательским библиотекам, которые доступны по умолчанию, если они есть.
Именно сюда будут устанавливаться модули если добавить флаг --user при установке чего-либо через pip
pip install --user requests
Для этой команды не нужны root-права.
После неё можно запускать системный интерпретатор без виртуальных окружений и установленная библиотека будет доступна для текущего юзера.
Параметр USER_BASE показывает корневую директорию для хранения user-библиотек. Её можно изменить с помощью переменной окружения PYTHONUSERBASE
export PYTHONUSERBASE=~/pylibs
python3 -m site
...
USER_BASE: '/home/user/pylibs'
USER_SITE: '/home/user/pylibs/lib/python3.7/site-packages'
Получается некоторое подобие виртуального окружения для бедных 😁 которое можно менять через эту переменную (не делайте так!Лучше venv!)
🔸 Дописывание пути в PYTHONPATH
Этот способ не входит в список "двух правильных", но тоже рабочий. Здесь придётся сделать всё несколько сложней.
Сначала ставим библиотеку в любое место указывая путь установки
pip3 install -t ~/mylibs modulename
Библиотека установится без привязки к какому-либо интерпретатору. То есть по умолчанию не будет видна. Теперь в нужный момент добавляем этот путь в sys.path или в PYTHONPATH.
Не буду советовать так делать. Единственный раз когда этот способ мне пригодился и решил поставленную задачу, это при создании общей библиотеки для кластера компьютеров.
Модули лежат в сети и подгружаются для всех из одного и того же места. То есть обновлять файлы требуется только один раз а не на всех хосты отдельно.
Минусы такого подхода:
▫️Нужно всем хостам пробить нужный путь в .bashrc или ещё куда-то чтобы он сетапился на старте.
▫️Чем больше хостов тем больше нагрузка на сеть. Иногда такой способ не подходит именно по этой причине. Тогда Ansible вам в помощь.
▫️Не очень подходит если хосты с разными операционками. Некоторые библиотеки различаются для Linux и Windows (там, где есть бинарники) и приходится мудрить более сложные схемы.
#tricks#basic
Xalqaro xotin-qizlar kuni bilan! 🥳
Aziz ayollar, sizni ushbu ajoyib bahor bayrami bilan tabriklaymiz, doimo gullar singari atrofdagilarni o‘z go‘zalligingiz va nafosatingiz bilan quvontirib yuring! 🥰
Barcha qiyinchiliklar sizni chetlab o‘tsin, qalbingizdagi mehr esa yaqinlaringizni va oila a'zolaringizni iliqlik bilan to‘ldirsin. 🫶
Biz sizni yaxshi ko‘ramiz, Kalleh jamoasi ❤️
➖
С Международным женским днем🥳
Милые дамы, поздравляем вас с этим чудесным весенним праздником и желаем, чтобы вы всегда, подобно цветам, радовали всех окружающих своей красотой и нежностью🥰
Пусть все невзгоды обходят вас стороной, а доброта сердца согревает родных и близких🫶
Мы вас любим, команда Kalleh❤️
#kalleh#8march
🎙 President of the Russian Federation Vladimir Putincongratulated the women of Russia on International Women’s Day, celebrated on March 8.
💬Dear women of Russia!
From the bottom of my heart, I congratulate you on International Women’s Day!
In our country, this wonderful holiday is traditionally filled with special warmth and sincerity. Today, words of love, gratitude and respect are heard everywhere. Our men express their appreciation to their mothers, wives, grandmothers, daughters, sisters, friends and colleagues, letting them know how much they are cherished and how deeply their contributions are valued, both at home and in the workplace, where they often take on complex professional challenges.
You truly do it all: taking care of children and scoring outstanding achievements in various fields, embodying both strength and grace, courage and tenderness, and winning us over again and again with your beauty and charm. You inspire men to strive for greatness, encouraging them to do better, to take bold steps and to be the true defenders of their families and homes, and our Motherland.
You hold within you life’s greatest miracle: the gift of bringing new life into the world. The tenderness and generosity of a mother’s heart and the warmth of a mother’s love transform the world and make it a better place. Motherhood is both an immense joy and a profound responsibility. We are fully aware of this and will continue to do our utmost so that mothers and families with children, especially large families, receive the support they need and see that their interests are always in the focus of the government’s attention.
My warmest words go to the women who are in places where it is most difficult right now, the participants in the special military operation. You are working in different spheres, including in field hospitals and on the front lines, doing your combat duty with distinction.
I would also like to say a few words for the women whose dear ones – husbands, fathers, brothers and loved ones – are defending the future of our country. Your heartfelt support and unfailing care, love and loyalty empower our men, strengthening their morale and the unwavering belief that the truth – and hence victory – is on our side.
Dear women!
We know that so much in life depends on you, on your talents, creative energy, love, and utmost responsibility with which you undertake any job. Once again, we are in awe of your beauty, kindness and grace.
I would like to wish success, health, well-being, and all the best to you and your loved ones. May you always find happiness alongside those you hold dear.
💐 Happy International Women’s Day!
#8March#InternationalWomensDay
🎙 President of the Russian Federation Vladimir Putincongratulated the women of Russia on International Women’s Day, celebrated on March 8.
💬Dear women of Russia!
From the bottom of my heart, I congratulate you on International Women’s Day!
In our country, this wonderful holiday is traditionally filled with special warmth and sincerity. Today, words of love, gratitude and respect are heard everywhere. Our men express their appreciation to their mothers, wives, grandmothers, daughters, sisters, friends and colleagues, letting them know how much they are cherished and how deeply their contributions are valued, both at home and in the workplace, where they often take on complex professional challenges.
You truly do it all: taking care of children and scoring outstanding achievements in various fields, embodying both strength and grace, courage and tenderness, and winning us over again and again with your beauty and charm. You inspire men to strive for greatness, encouraging them to do better, to take bold steps and to be the true defenders of their families and homes, and our Motherland.
You hold within you life’s greatest miracle: the gift of bringing new life into the world. The tenderness and generosity of a mother’s heart and the warmth of a mother’s love transform the world and make it a better place. Motherhood is both an immense joy and a profound responsibility. We are fully aware of this and will continue to do our utmost so that mothers and families with children, especially large families, receive the support they need and see that their interests are always in the focus of the government’s attention.
My warmest words go to the women who are in places where it is most difficult right now, the participants in the special military operation. You are working in different spheres, including in field hospitals and on the front lines, doing your combat duty with distinction.
I would also like to say a few words for the women whose dear ones – husbands, fathers, brothers and loved ones – are defending the future of our country. Your heartfelt support and unfailing care, love and loyalty empower our men, strengthening their morale and the unwavering belief that the truth – and hence victory – is on our side.
Dear women!
We know that so much in life depends on you, on your talents, creative energy, love, and utmost responsibility with which you undertake any job. Once again, we are in awe of your beauty, kindness and grace.
I would like to wish success, health, well-being, and all the best to you and your loved ones. May you always find happiness alongside those you hold dear.
💐 Happy International Women’s Day!
#8March#InternationalWomensDay
🎙 President of the Russian Federation Vladimir Putincongratulated the women of Russia on International Women’s Day, celebrated on March 8.
💬Dear women of Russia!
From the bottom of my heart, I congratulate you on International Women’s Day!
In our country, this wonderful holiday is traditionally filled with special warmth and sincerity. Today, words of love, gratitude and respect are heard everywhere. Our men express their appreciation to their mothers, wives, grandmothers, daughters, sisters, friends and colleagues, letting them know how much they are cherished and how deeply their contributions are valued, both at home and in the workplace, where they often take on complex professional challenges.
You truly do it all: taking care of children and scoring outstanding achievements in various fields, embodying both strength and grace, courage and tenderness, and winning us over again and again with your beauty and charm. You inspire men to strive for greatness, encouraging them to do better, to take bold steps and to be the true defenders of their families and homes, and our Motherland.
You hold within you life’s greatest miracle: the gift of bringing new life into the world. The tenderness and generosity of a mother’s heart and the warmth of a mother’s love transform the world and make it a better place. Motherhood is both an immense joy and a profound responsibility. We are fully aware of this and will continue to do our utmost so that mothers and families with children, especially large families, receive the support they need and see that their interests are always in the focus of the government’s attention.
My warmest words go to the women who are in places where it is most difficult right now, the participants in the special military operation. You are working in different spheres, including in field hospitals and on the front lines, doing your combat duty with distinction.
I would also like to say a few words for the women whose dear ones – husbands, fathers, brothers and loved ones – are defending the future of our country. Your heartfelt support and unfailing care, love and loyalty empower our men, strengthening their morale and the unwavering belief that the truth – and hence victory – is on our side.
Dear women!
We know that so much in life depends on you, on your talents, creative energy, love, and utmost responsibility with which you undertake any job. Once again, we are in awe of your beauty, kindness and grace.
I would like to wish success, health, well-being, and all the best to you and your loved ones. May you always find happiness alongside those you hold dear.
💐 Happy International Women’s Day!
#8March#InternationalWomensDay
🎙 President of the Russian Federation Vladimir Putincongratulated the women of Russia on International Women’s Day, celebrated on March 8.
💬Dear women of Russia!
From the bottom of my heart, I congratulate you on International Women’s Day!
In our country, this wonderful holiday is traditionally filled with special warmth and sincerity. Today, words of love, gratitude and respect are heard everywhere. Our men express their appreciation to their mothers, wives, grandmothers, daughters, sisters, friends and colleagues, letting them know how much they are cherished and how deeply their contributions are valued, both at home and in the workplace, where they often take on complex professional challenges.
You truly do it all: taking care of children and scoring outstanding achievements in various fields, embodying both strength and grace, courage and tenderness, and winning us over again and again with your beauty and charm. You inspire men to strive for greatness, encouraging them to do better, to take bold steps and to be the true defenders of their families and homes, and our Motherland.
You hold within you life’s greatest miracle: the gift of bringing new life into the world. The tenderness and generosity of a mother’s heart and the warmth of a mother’s love transform the world and make it a better place. Motherhood is both an immense joy and a profound responsibility. We are fully aware of this and will continue to do our utmost so that mothers and families with children, especially large families, receive the support they need and see that their interests are always in the focus of the government’s attention.
My warmest words go to the women who are in places where it is most difficult right now, the participants in the special military operation. You are working in different spheres, including in field hospitals and on the front lines, doing your combat duty with distinction.
I would also like to say a few words for the women whose dear ones – husbands, fathers, brothers and loved ones – are defending the future of our country. Your heartfelt support and unfailing care, love and loyalty empower our men, strengthening their morale and the unwavering belief that the truth – and hence victory – is on our side.
Dear women!
We know that so much in life depends on you, on your talents, creative energy, love, and utmost responsibility with which you undertake any job. Once again, we are in awe of your beauty, kindness and grace.
I would like to wish success, health, well-being, and all the best to you and your loved ones. May you always find happiness alongside those you hold dear.
💐 Happy International Women’s Day!
#8March#InternationalWomensDay
Девчонки, с праздником весны!
Вы так прекрасны, как цветы.
Спасибо, что со мной всегда —
В дожди и в ясные года.
Желаю вам любви, тепла,
Чтоб жизнь, как кимчи, жила была! 😁
Пусть дома пахнет вкуснотой,
А в сердце — вечная весна!
С 8 Марта! Обнимаю крепко 💐
#8march#8марта#kim_chi_kim
Дорогие наши женщины, матери, сестры, жены и дочери!
Сердечно поздравляем вас с праздником весны, красоты и женственности — с 8 Марта!
Сегодня, находясь на передовой, мы особенно остро чувствуем вашу поддержку, тепло ваших сердец и вашу бесконечную любовь. Вы — наша опора, наше вдохновение и наша сила.
Мы знаем, как непросто вам в эти дни, но ваша стойкость и вера помогают нам идти вперед. Спасибо вам за ваше терпение, за вашу заботу и за то, что вы всегда с нами, даже на расстоянии.
Пусть этот день принесет вам радость, улыбки и надежду на скорую встречу. Мы верим, что мирное небо скоро вернется, а наши сердца снова будут рядом с вами.
С праздником, дорогие! Вы — наши героини!
С любовью и уважением, ваши бойцы.
#8марта#8march#поздравления
KNAUF kompaniyasida turfa xil kasb egalari: muhandislar, buxgalterlar, sifat, logistika, xavfsizlik, xodimlar boshqaruvi va investitsiyalar bo‘yicha mutaxassislar ishlaydi.
Har kuni ular ishlab chiqarish jarayonlarining barqaror faoliyati, loyihalar rivoji va yuqori sifat darajasini ta’minlab keladilar.
Ularning tajribasi, kasb bilimdonligi va tafsilotlarga e’tibori kompaniyaning olgʻa yurishiga turtki beradi.
Xalqaro xotin-qizlar kunida biz sizni jamoamizning dur-u gavharlari – KNAUF rivojiga ulkan hissa qo‘shib kelayotgan ayollar bilan tanishtirmoqchimiz.
Mehnatingiz, mas’uliyatingiz va g‘ayratingiz uchun tashakkur.
8-mart bayrami muborak!
- - - - -
В КНАУФ работают люди самых разных профессий — инженеры, бухгалтеры, специалисты по качеству, логистике, безопасности, управлению персоналом и инвестициям.
Каждый день они обеспечивают стабильную работу производства, развитие проектов и высокий уровень качества.
Их опыт, профессионализм и внимание к деталям помогают компании двигаться вперёд.
В Международный женский день мы хотим познакомить вас с частью нашей команды — женщинами КНАУФ, которые вносят огромный вклад в развитие компании.
Спасибо за ваш труд, ответственность и энергию.
С праздником 8 марта!
#knaufuzbekistan
#buildonus
#KNAUF_Yangiliklar
#8mart
#8march
🌷Happy International Women’s Day!
The Russian House in Brussels warmly congratulates all women on the occasion of 8 March.
This special day is a celebration of the strength, wisdom, talent, and inspiration that women bring to our world. Throughout history, women have played an essential role in society — preserving cultural traditions, inspiring creativity, and contributing to the development of communities and dialogue between nations.
May this spring bring you joy, new inspiration, warmth, and happiness. We wish you good health, prosperity, and many bright moments filled with smiles and kindness.
With best wishes on the holiday of spring, beauty, and inspiration!🌸
Russian House in Brussels
#InternationalWomensDay#8March#RussianHouseBrussels#WomenInspire#SpringHoliday
🤗 Дорогие женщины,
Коллектив Русского дома поздравляет вас с Международным женским днём #8Марта!
Пусть этот весенний праздник наполнит ваши сердца энергией и радостью, подарит отличное настроение и искренние улыбки! Пусть в ваших домах царят любовь, счастье, тепло, уют и благополучие! 💐
🤗 Αγαπητές γυναίκες,
Το Ρωσικό σπίτι στην Αθήνα σας συγχαίρει θερμά για την Παγκόσμια Ημέρα της Γυναίκας, #8 Μαρτίου!
Είθε αυτή η ανοιξιάτικη γιορτή να γεμίσει τις καρδιές σας με ενέργεια και χαρά, να σας προσφέρει υπέροχη διάθεση και ειλικρινή χαμόγελα! Είθε να βασιλεύει στα σπίτια σας η αγάπη, η ευτυχία, η ζεστασιά, η θαλπωρή και η ευημερία! 💐
Με τις καλύτερες ευχές μας για μια υπέροχη ημέρα!
#женскийдень#праздник#8марта#8μαρτίου#8march#международныйженскийдень#παγκοσμιαημεραγυναικας#holiday#8march#8μαρτίου#internationalwomensday#παγκοσμιαημεραγυναικας
🤗 Αγαπητές γυναίκες,
Το Ρωσικό σπίτι στην Αθήνα σας συγχαίρει θερμά για την Παγκόσμια Ημέρα της Γυναίκας, #8 Μαρτίου!
Είθε αυτή η ανοιξιάτικη γιορτή να γεμίσει τις καρδιές σας με ενέργεια και χαρά, να σας προσφέρει υπέροχη διάθεση και ειλικρινή χαμόγελα! Είθε να βασιλεύει στα σπίτια σας η αγάπη, η ευτυχία, η ζεστασιά, η θαλπωρή και η ευημερία! 💐
Με τις καλύτερες ευχές μας για μια υπέροχη ημέρα!
🤗 Дорогие женщины,
Коллектив Русского дома поздравляет вас с Международным женским днём #8Марта!
Пусть этот весенний праздник наполнит ваши сердца энергией и радостью, подарит отличное настроение и искренние улыбки! Пусть в ваших домах царят любовь, счастье, тепло, уют и благополучие! 💐
@rossotrudnichestvo@rusembgreece
#женскийдень#праздник#8марта#8μαρτίου#8march#международныйженскийдень#παγκοσμιαημεραγυναικας
#womensday#holiday#8march#8μαρτίου#internationalwomensday#παγκοσμιαημεραγυναικας