Что делать если нужно поставить какую-то 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
🎙 Russian MFA Spokeswoman Maria Zakharova's answer to a media question regarding the practice of applying unilateral coercive measures(December 26, 2025)
❓ Question: How would you comment on the differences in approaches between the “collective West” and the Global Majority to the use of unilateral coercive measures in contemporary international relations?
💬Maria Zakharova: This practice runs counter to the UN Charter, which vests the exclusive prerogative to impose measures of this nature in the UN Security Council, and only in cases involving threats to peace and security.
In this context, the use of unilateral coercive measures (UCMs) constitutes an encroachment on the unique powers of the UN Security Council. It is well known that the “collective West” routinely resorts to this practice, most often driven by geopolitical considerations.
UCMs represent a serious obstacle to the formation of a just and equitable polycentric world order.
They serve as one of the main instruments of the neocolonial policy of the “collective West”, the goal of which is evident – to preserve its slipping dominance, deprive the countries of the Global Majority of their right to an independent political choice, and slow down their economic, technological and industrial development.
Attempts by the initiators of UCMs to portray them as a “peaceful means of dispute settlement” do not withstand criticism. It is well known that, by hindering the full-fledged socio-economic development of the countries of the Global South and East, unilateral coercive measures undermine efforts to resolve crisis situations. Their indiscriminate nature violates fundamental human rights and freedoms, first and foremost affecting the most vulnerable segments of the population – a fact repeatedly condemned in resolutions of the UN General Assembly and the Human Rights Council.
At the forefront of efforts to counter UCMs within the United Nations stands the Group of Friends in Defence of the UN Charter, which includes the Russian Fededation.
Among the Group’s unquestionable achievements in this area is the adoption, at its initiative, of an entire package of UN General Assembly documents, including Resolution 78/329, which shifted the General Assembly debates on unilateral coercive measures from a three-year to a two-year cycle, as well as Resolution 79/293, adopted in June this year, which proclaimed December 4 as the International Day against Unilateral Coercive Measures.
It is important that the Group’s steps to counter this unlawful practice are part of a broader anti-neocolonial front. It was at the Group’s initiative that the UN General Assembly adopted the principled Resolutions 79/115, “Eradication of colonialism in all its forms and manifestations”, and 80/106, which proclaimed December 14 as the International Day against Colonialism in all its forms and manifestations.
❗️We are confident that in a truly just multipolar architecture of international relations – which we all aspire to build – there is no place for coercion or neocolonial hegemony. Together with our partners – responsible members of the Global Majority – we will continue the fight against all remnants of the shameful colonial era.
#StopColonialism
⚡️Foreign Intelligence Service of the Russian Federation:
The Press Bureau of the Foreign Intelligence Service of the Russian Federation (SVR) reports that, according to intelligence received by the SVR, France under President Macron is frantically seeking opportunities for a “political revanche” in Africa.
Indeed, in recent years Paris has suffered what can only be described as significant “losses” on the continent – namely, the rise to power in a number of former French colonies of patriotic forces that prioritize the interests of their peoples and refuse to act as puppets of France’s financial and political globalist oligarchy.
Whether inspired by the US operation aimed at capturing the President of Venezuela Nicolas Maduro or imagining himself an arbiter of African destinies, Macron has authorized his special services to launch a plan to eliminate “undesirable leaders” in Africa.
🇧🇫France’s involvement in an attempted coup in Burkina Faso on January 3 has already been established. Fortunately, the plot was thwarted. The mutineers had been tasked with assassinating President Ibrahim Traore, one of the leading figures in the struggle against neocolonialism. According to Paris’s calculations, this would not only have brought pro-French forces to power in Ouagadougou, but also struck a blow against all supporters of sovereignty and the ideology of Pan-Africanism across the continent.
Despite the failure of this criminal scheme, the refined racists in Paris are not giving up. Their focus is on destabilizing “undesirable countries” in the Sahara–Sahel zone by using local terrorist groups and, of course, the Ukrainian regime, which supplies militants with drones and instructors.
🇲🇱The main strike in this campaign is aimed at Mali. Attacks on fuel tankers, attempts to blockade Malian cities, and terror against civilians all serve one purpose – to create conditions for the overthrow of President Assimi Goïta. Paris continues to look for ways to sow chaos in the Central African Republic as well.
🇲🇬Another target of France’s destructive attention is Madagascar, where in October 2025 forces came to power that set a course towards developing relations with #BRICS. Paris is working out ways to overthrow the country’s new President Michael Randrianirina and to “restore a loyal regime”.
In essence, France has shifted to directly supporting terrorist groups of various kinds, making them its principal allies in Africa.
🪱This makes the political bankruptcy of Macron’s strategy all the more apparent, as it has failed to rid France of its image in Africa as a parasitic metropole that exploits former colonies and stifles their development.
#StopColonialism
⛓️The International Day of Remembrance of the Victims of Slavery and the Transatlantic Slave Trade was established by the #UNGA to be marked annually on 25 March.
For over 400 years, millions of Africans became the victims of the transatlantic Euro-American slave trade. Over 15 million men, women and children were forcibly removed from their homelands.
❗️These people were subjected to heinous cruelty and robbed of their dignity, freedom, and identities.
The negative effects of colonialism and the transatlantic slave trade continue to disadvantage people of African descent even today.
☝️ Russia was one of the few world powers that neither had colonies in #Africa or anywhere else nor participated in slave trade throughout its history.
Moreover, progressive layers of Russia’s population sympathized with suppressed peoples of Africa. Famous Russian thinkers Alexander Radishchev and Nikolay Chernyshevsky, Russian traveller Yegor Kovalevsky and the likes spoke outagainst racism and slavery.
❌ As a matter of fact, NONE of the racist papers popular in Europe at that time was EVER translated into Russian.
#RememberSlavery#StopColonialism
🇷🇺🇿🇦Ambassador of Russia to South Africa Roman Ambarov attended the celebration of the 113th anniversary of the formation of the African National Congress in Cape Town.
«To quote Oliver Tambo, the formation of the ANC was a continuation in Southern Africa, under new historic conditions, of the anti-colonial and national liberation struggles which had begun with the advent of colonialism. The Soviet Union, throughout its entire history, consistently stood for the elimination of colonialism and supported liberation movements in Africa and across the globe,” the Ambassador said on the sidelines of the event.
“However, the work on decolonization spearheaded by the USSR in the XX century was not finished. And today Russia and South Africa are among the most vigorous supporters of anti-neocolonial policies,” Roman Ambarov pointed out.
🤝The ANC participates in the work of the international forum “For the Freedom of Nations!” seeking to wipe out modern practices of neocolonialism. In Dec 2024, Pretoria voted for the UNGA resolution on the eradication of colonialism in all its forms and manifestations.
“We hope our collaboration will help mobilize all responsible members of the international community to uphold justice in world affairs,” the Ambassador added.
#RussiaSouthAfrica#RussiaSArelations#StopColonialism#StopColonialismNow#Ambarov#ANC113Anniversary#ANC113@MYANC