Что делать если нужно поставить какую-то 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
💥Massive: Humanity Protocol closed another $20M funding round
💯 FreeAirdrop
💰Funding - $50M
💰Valuation - $1.1B
✅👇Steps:
🔗Sign-up Link:testnet.humanity.org
✅Enter the referral code below to receive a bonus:
airdropgold
⭕️How to Participate:
1️⃣ Click the link above.
2️⃣ Sign in using your email or wallet.
3️⃣ Complete your account details.
4️⃣ Connect your social networks (10% bonus per social).
5️⃣ Claim RWA tokens daily.
⭕️Discord Task:
1️⃣ Join their Discord
2️⃣ Go to the Human-ID section.
3️⃣ Click Submit and enter your wallet address.
4️⃣ Confirm to receive the Human role.
#Humanity
文化正在回归
https://x.com/dioscuri/status/2043661976534950323
Henry Shevlin 加入 DeepMind 作为哲学研究员。据我所知,Anthropic 和谷歌是目前哲学家含量最高的 AI 公司,Amanda Askell 一直在参与和推动 Claude Code,Mythos 系统卡明确引用马克·费舍尔;自然哲学家 Richard Ngo 参与过 Deepmind 和 OpenAI 的研究工作;作家 Steven Johnson 一直在 Notebooklm 幕后工作。
Midjourney, Linear, Every 这些科技公司都曾公开招聘哲学家、作家和记者。
#humanity
文化正在回归
https://x.com/dioscuri/status/2043661976534950323
Henry Shevlin 加入 DeepMind 作为哲学研究员。据我所知,Anthropic 和谷歌是目前哲学家含量最高的 AI 公司,Amanda Askell 一直在参与和推动 Claude Code,Mythos 系统卡明确引用马克·费舍尔;自然哲学家 Richard Ngo 参与过 Deepmind 和 OpenAI 的研究工作;作家 Steven Johnson 一直在 Notebooklm 幕后工作。
Midjourney, Linear, Every 这些科技公司都曾公开招聘哲学家、作家和记者。
#humanity
1983 年,乔布斯给一位索要签名的人写了这封信。
https://x.com/JonErlichman/status/1996653675755065399
Dear M. Varon:
I'm honored that you'd write, but I'm afraid I don't sign autographs.
#humanity
#qidirilmoqda
#humanity
📢DIQQAT! SHOSHILINCH E’LON!
🆘 Suratdagi, 2007-yilda tug‘ilgan, bundan ikki oy avval Turkiyaga kelgan Turkmaniston fuqarosi Nurana Gurbangeldiyeva ismli 18 yoshli qiz, 1-oktyabr kuni İstanbul’dagi uydan chiqib ketib, hanuz qaytib kelmagan. Onasi juda tashvishda.
🔎 U haqida biror ma’lumotga ega bo‘lgan, ko‘rgan yoki eshitgan insonlardan zudlik bilan quyidagi telefon raqamlariga qo‘ng‘iroq qilib xabar berishlarini so‘raymiz.
🛑 Har biringizning e’tiboringiz va hamjihatligingiz biz uchun juda muhim. Bir insonning taqdiri befarqlikda qolmasin!
📞Aloqa uchun telefon raqamlari:
📞 0552 612 22 54
📞 0501 488 54 56
🤝 Yordam va xabaringiz uchun oldindan minnatdorlik bildiramiz.
🆘
🆘
🆘
🆘
🆘
🆘
🆘
📢DİKKAT! ACİL DUYURU!
🆘 Fotoğraftaki, 2007 doğumlu, iki ay önce Türkiye’ye gelen Türkmenistan vatandaşı Nurana Gurbangeldiyeva isimli 18 yaşındaki genç kız, 1 Ekim günü İstanbul’daki evinden çıkmış ve hâlâ geri dönmemiştir.Annesi perişan durumda.
🔎 Kendisi hakkında herhangi bir bilgiye sahip olan, gören veya duyanların derhal aşağıdaki telefon numaralarına ulaşarak haber vermelerini önemle rica ediyoruz.
🛑
Her birinizin dikkati ve dayanışması bizim için çok değerlidir.
Bir insanın kaderi ilgisizlikte kaybolmasın!
📞İletişim numaraları:
📞 0552 612 22 54
📞 0501 488 54 56
🤝 Yardımınız ve vereceğiniz bilgi için şimdiden teşekkür ederiz.
🌎 In Sulawesi’s limestone caves, ancient hand stencils date back over 39,000 years—among the oldest known art made by humans anywhere on Earth. ✨
#archaeology⚡#caveart⚡#humanity
👉subscribe Interesting Planet
🔤🔤🔤🔤🔤🔤🔤
Guys, some of you already heard about testnets, some of you not.
We would like to introduce you the first one called, Humanity protocol.
You need to claim your reward every 6 hours without clicking, entering combo and etc.
$RWT token is already trading.
Join humanity protocol👉link
#Testnet#Humanity#Protocol
"In 2014, my son was battling cancer.
At one point, we were desperately looking for O-negative blood, a rare type, and time was not on our side. It was the first time I turned to social media. Until then, it was just a page. Nothing more.
But that day, it became something else. People responded. People shared. People prayed. And it meant more to me than I can ever express.
Among all the moments I witnessed, and one day I may write about that chapter of my life, there is one I will never forget.
A woman came from the South of Lebanon. From Bint Jbeil, from the heart of the South. Her son drove her for hours, 5 hours, just to reach us.
I remember them walking into that small salon where we were sitting. I was with my brother. She looked at me and said: “I know you are looking for this blood type. I have it. I asked my son to bring me. We searched for you in Beirut’s hospitals … and now we found you. I am here to give my blood to your son”.
She came to give life … to my son.
And this is the first time, I talk about it, even to my wife.
These are the people of the South.
Today, the South is being destroyed, villages are being erased. And I cannot help but think of her and of so many others like her.
This is my country. These are my people. From every region, every village, every belief. And in my own way, as a human being, and through my voice, I will always stand by every suffering, every pain, every cry for help.
To the Lebanese South and to every family living through this agony today, I send my love. May God save your beautiful hearts ❤️🇱🇧
#lebanon#humanity#unity#لبنان"
https://x.com/RicardoRKaram/status/2043399704487100506?t=78lhBlcqqGnk1SNOsxtYDQ&s=19
🕊 The Philosophy of Ubuntu
Ubuntu is a core concept in the cultures of southern Africa, including South Africa🇿🇦
Rooted in the Bantu languages, it is often translated as:
“I am because we are.”
Ubuntu is about humanity, compassion, mutual support, and the ability to forgive🤝
👐Nelson Mandela believed that everyone has the power to change the world — starting with respect for others:
💬 “Ubuntu does not mean that people should not enrich themselves. The question is: are you going to do so in order to enable the community around you to be able to improve?”
— Nelson Mandela
🌍 On Mandela Day 🗓 July 18, supporters of the Ubuntu philosophy around the world dedicate 67 minutes to acts of kindness, honoring 67 years of Nelson Mandela’s service to society ❤️
#Ubuntu#NelsonMandela#SouthAfrica#Philosophy#Humanity#MandelaDay