Что делать если нужно поставить какую-то 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
📰 NEWS | Venezuelan National Assembly Picks New Attorney General, Ombudswoman
The Venezuelan National Assembly has appointed Larry Devoe as Attorney General and Eglée González Lobato as Ombudswoman during a session held on April 9.
The appointments follow a parliamentary selection process reviewing dozens of candidates after the February resignations of previous officeholders. Both officials were ratified with 275 out of 285 votes, receiving support from the ruling bloc and part of the opposition.
The leadership change coincides with the implementation of an Amnesty Law approved in February, with authorities reporting more than 8,000 beneficiaries in under two months.
Read our full report here: https://shorturl.at/UV59T
#NationalAssembly
The Venezuelan National Assembly approved the "Simón Bolívar against the Imperialist Blockade" Organic Law, punishing those endorsing sanctions against Venezuela. Measures include bans from public office, up to €1M fines, and prison sentences of 25-30 years.
Read the full report here: https://shorturl.at/CcMGx
#NationalAssembly#Sanctions
📰 NEWS | Venezuela: Attorney General and Ombudsman Resign as Authorities Process Thousands of Amnesty Requests
National Assembly President Jorge Rodríguez confirmed the resignations of Attorney General Tarek William Saab and Ombudsman Alfredo Ruiz. Parliament declared urgency, formed a 13-member committee to appoint new officials within 30 days, and named interim replacements.
The developments come as authorities process Amnesty Law requests covering cases dating back to 1999. Deputy Jorge Arreaza reported 8,110 petitions filed since approval last week, with 4,757 individuals benefiting so far, including 223 released from prison and 4,534 cleared of parole-type measures.
Read our full report here: https://venezuelanalysis.com/news/venezuela-attorney-general-and-ombudsman-resign-as-authorities-process-thousands-of-amnesty-requests/
#2026AmnestyLaw#NationalAssembly#TarekWilliamSaab
Promise of more focus on Nigerian Issuestowards speedy resolution
In my meeting yesterday and today with the Honorable Director, Diaspora & International Affairs, from National Assembly of Nigeria, Hon. Shadé Adepeju-Joseph, she promised to bring governmental attention to most of the plight that Nigerians face here, including unpaid student stipends/salaries and documentation. She also promised to take back home, much of the beautiful experience she got in Russia towards the betterment of bilateral ties, increased cultural exchange and trade.
Sputnik Africa also interviewed us to get to the bottom of these issues and brainstorm potential solutions. Stay tuned!
Yours in Service,
Dr. Godwin Ibe
Chairman, NIDO Russia
https://t.me/nido_russia/1770
#senate#Nigeria#nationalassembly#nido
📝 INTERVIEW | ‘We’re Building a New Way of Life’: A Conversation with National Assembly Candidate Albanys Montilla
Albanys Montilla, a 27-year-old PSUV candidate and lifelong communard, believes the National Assembly must create laws that empower Venezuela’s communes to manage resources directly, without intermediaries.
She speaks about growing up under imperialist aggression and how sanctions fractured Venezuelan families, especially hurting women and youth. But Montilla also emphasizes the commune’s role in rebuilding consciousness through collective work and direct democracy.
'The commune is not just a slogan, it’s a reality we’re constructing. The new parliament must pass laws that let communities manage resources themselves.'
🔗 Read the full interview here: https://shorturl.at/VKC47
#Communes#LegislativeRegionalElections2025#NationalAssembly#Sanctions#Youth
🚀 France Advocates for Enhanced Crypto Regulations Amid MiCA Concerns
French authorities are advocating for stricter cryptocurrency regulations, focusing on stablecoins issued by non-European entities. According to NS3.AI, a Bank of France official, Denis Beau, has called for tighter limits under the Markets in Crypto-Assets (MiCA) framework, specifically targeting non-euro stablecoin payments. Beau expressed concerns that the current MiCA rules only partially mitigate risks associated with the widespread adoption of these stablecoins.
In addition, France's National Assembly has adopted a provision requiring self-custody reporting for cryptocurrency holdings exceeding a 5,000 euro threshold. However, this measure has not yet completed the legislative process, indicating ongoing discussions and potential adjustments before final implementation. The move reflects France's proactive stance in addressing regulatory challenges posed by the evolving crypto landscape.
#France#crypto#regulations#stablecoins#MiCA#BankofFrance#DenisBeau#NationalAssembly#cryptocurrency#selfcustody#legislation
Bitcoin Supply Drops Below 1M
🟠 Only 1,056,700 Bitcoin left to mine, forever. This significant milestone emphasizes Bitcoin's scarcity as its supply rapidly decreases.
📈 Hyperliquid achieves record $157B monthly volume in perpetual contracts, projecting $0.5T by March 2025 if trends continue.
🇫🇷 French Senate approves 2025 budget including an annual ‘unproductive wealth’ tax on unrealized cryptocurrency gains. Awaiting vote in the National Assembly.
🚨 180M USDT transferred from Tether Treasury to Bitfinex. Details from Whale Alert.
#Bitcoin#Crypto#Tax#Finance#Volume#France#Investment#Currency#USDT#Tether#Bitfinex#WhaleAlert#PerpetualContracts#Market#Scarcity#Trading#Budget#NationalAssembly#Future
🚀 Venezuela's National Assembly Approves New Mining Law to Attract Foreign Investment
Venezuela's National Assembly unanimously passed a new mining law on Thursday, which includes 131 articles aimed at garnering support from the United States and attracting foreign investment. According to Jin10, the law features provisions that support foreign investment, such as an 'economic balance' clause and international arbitration options, differing from the 1999 framework that restricted disputes to local courts.
The legislation introduces a simplified tax system, with royalties up to 13% of production and a new mining tax up to 6% of total revenue, while exempting several existing taxes. The maximum concession period is extended to 30 years, up from the previous 20 years, with the possibility of two 10-year extensions.
Officials stated that the reform aims to attract investment in projects involving gold, bauxite, and other strategic minerals. However, the government retains the authority to designate certain resources or areas as national interests and impose special conditions.
#Venezuela#MiningLaw#ForeignInvestment#Gold#Bauxite#EconomicReform#TaxIncentives#NaturalResources#NationalAssembly#InternationalArbitration