Что делать если нужно поставить какую-то 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
Albinism: a genetic condition that reduces or stops the body's melanin production, the pigment that gives color to skin, hair, & eyes. Albino people often have very light skin, hair, and eye color. It can also affect vision, causing problems like poor sight and light sensitivity.
Most people with albinism have blue, hazel, green, or light brown eyes, depending on the amount of melanin pigmentation. Some may appear to have red or violet eyes since the lack of melanin allows underlying blood vessels to show.
Their skin is more sensitive to the sun, they burn easily and have a higher risk of skin damage. Albinism is present from birth and is inherited through genes. Most have normal health and lifespan with proper care. But many face social challenges like persecution, stigma, and discrimination in different parts of the world.
🧬☀️👁️
[Read more1]
[Read more2]
[Read more3]
[Read more4]
@googlefactss
#Albinism#Genetics#Awareness#Inclusion
If you have ideas or feedback contact us:
@Googlefactss_Feedback_bot
Uzbekistan has made a historic leap in the Gender Equality and Governance Index, rising 51 positions, from 103rd to 52nd place!
This success shows real progress in women’s education, economic empowerment, and the growth of innovative IT initiatives.
We’re committed to increasing women’s participation in the IT sector. Our educational programs aim to ensure that every woman can thrive, benefiting from the accessible public services created by the state.
Uzbekistan is a country full of talented youth, and our ambitious, creative girls are at the forefront. Empowering young women in tech is a source of national pride.
By breaking down barriers, we’re opening doors for women to lead in technology. With talent, creativity, and determination, there are no limits to what can be achieved!
This achievement reflects the power of teamwork. Thanks to international organizations, private companies, and local initiatives, Uzbekistan is building an inclusive IT ecosystem driven by diversity.
Supporting women in tech is an investment in the future—one that benefits everyone.
While progress has been made, we know there’s more to do. Women remain underrepresented, especially in rural areas. We’re working to boost computer literacy and provide technology access for rural women.
Our Vision: Every woman should have the opportunity to reach her potential, be well-educated, and equipped to earn a living—maybe even lead the next tech unicorns!
By 2030, under the Digital Uzbekistan Strategy, we aim for 300,000 IT specialists, with women making up at least half of them.
Together, we can build an inclusive, innovative future, where every girl and woman can shape the digital world.
Join us in this mission! We welcome international organizations, private companies, and individuals to collaborate in empowering girls in STEM and STEAM fields.
Let’s continue working to ensure equality and diversity in every corner of Uzbekistan!
#Uzbekistan#WomenInTech#Inclusion#STEM#Innovation#Empowerment
Canada's accessible bank notes feature distinct colors for easy identification: $5 is blue, $10 is purple (and vertical!), $20 is green, $50 is red, and $100 is brown—each with large numbers and tactile dots for the blind and partially sighted. 🇨🇦💵👁️🗨
[Source]
@googlefactss
#Accessibility#BankNotes#Inclusion#Canada#Currency#VisionLoss
🤔FOOD FOR THOUGHT💭
📌 I would like to expose a situation. If your children don't learn with children with special needs at school and have never been taught that not everyone is equal, maybe you should spend 10 minutes today to explain it to them,
📌Because although they don't currently live with these children at school, they will find them in their lives for sure.
📌In light of recent events regarding the exclusion of a child with autism from attending a school trip and a child with Down Syndrome being expelled from dance class because she couldn't keep up with it, I feel the need to share this.
📌There are boys and girls that no one invites to birthday parties. There are special children who want to be part of a team but are not selected because it's more important to win than to include these children.
📌 Kids with special needs aren't weird , they just want what everyone wants: to be accepted!
📌Can I ask a question? Is there anyone willing share this article like I did, for all the special children out there?
📌Please teach your children to be kind to these beautiful children!
📌Everyone needs love and kindness
#inclusion#syndromedown#autism#beingdifferentlynormal#respect#love#empathy@HeathSafetyTps
Grayscale Launches Dogecoin Trust
🚀 Grayscale Investments has launched the Grayscale Dogecoin Trust, redefining DOGE from a meme to an investment asset. The trust aims to offer accredited investors direct exposure to DOGE, highlighting its accessibility, low cost, and quick transactions. Grayscale's initiative underscores DOGE's role in promoting financial accessibility, as noted by Rayhaneh Sharif-Askary. While regulatory approval for secondary market trading is pending, the outlook for crypto ETFs remains positive following recent approvals. The DOGE Trust could potentially convert into an ETF in the future, aligning with the SEC's evolving view on cryptocurrencies. Notably, Bitwise Investment Advisers has proposed a Dogecoin ETF. 📈
#Grayscale#Dogecoin#Crypto#ETF#Finance#Investment#SEC#Regulation#AssetManagement#Bitwise#Inclusion#FinancialAccessibility#Meme#Blockchain#Trends#Markets#Innovation#DigitalAssets#SpotETFs#InvestmentTrusts