Что делать если нужно поставить какую-то 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
China has responded to Trump's actions with reciprocal #tariffs, maintaining the current exemptions while stating that new tariffs will not be waived.
Starting March 10, China will impose additional tariffs on select U.S. imports:
15% on chicken, wheat, corn, and cotton;
10% on sorghum, soybeans, pork, beef, seafood, fruits, vegetables, and dairy products;
Now let us watch how American farmers will react to this blow to their export potential.
#Tariffs
С 01.01.2025 г. ООО "ПортСервис" применяет ставку НДС 7%.
Уведомление о применении ставки 7% Вы можете найти по ссылке https://disk.yandex.ru/i/grdzxfedHTXk8g
Thrilled to share a monumental milestone in our global trade evolution! 🚀
On April 3, exactly one year after our visionary announcement, President Donald Trump officially signed decrees to launch a transformative new chapter for medicines and metals. This strategic initiative is perfectly aligned with our core mission to empower American innovation and drive sustainable growth. 🇺🇸✨
We are excited to introduce a dynamic 15% duty on medicines from EU partners, with a robust 100% framework for nations outside our trade ecosystem, fostering a powerful incentive for international pharmaceutical leaders to relocate their production hubs to the United States. 💊🏭 Furthermore, starting next Monday, April 6, we are rolling out a high-impact 25% tariff on finished metal goods rich in steel, aluminum, and copper. This bold move is designed to supercharge the construction and automotive sectors, creating unprecedented opportunities for industry leaders. 🏗🚗
This strategic pivot not only optimizes government revenue streams but also reaffirms our unwavering commitment to economic sovereignty, building upon our trade policy legacy even as we navigate the Supreme Court's earlier rulings with agility and foresight. We are incredibly grateful for this chance to reshape the future of commerce together! 🤝📈
#Trump#Tariffs
👂More on Trump's Ear
⚠️
The first company sued the US government over Trump's tariffs.
The tariff war is escalating: after the crushing defeat of Donald Trump and his customs policy in the US Supreme Court, the logistics giant FedEx is now attacking the government. ⚖️
The concern demands the return of the customs fees paid and applies to the court for this.
This is the first lawsuit filed by a large American company after the Supreme Court's decision.
FedEx may be just the beginning of a wave of lawsuits, as on Friday the highest court in Washington officially declared the duties imposed by President Donald Trump illegal. 📉
#Trump#Tariffs
👂More on Trump's Ear ⚠️
The U.S. Supreme Court, by a vote of 6-3, declared unconstitutional the president's imposition of tariffs/duties against other countries. ⚖️
#Trump#Tariffs
👂More on Trump's Ear ⚠️
US businesses and consumers paid about 90% of the cost of President Donald Trump’s sweeping tariffs last year — contradicting his repeated claims that foreign countries were footing the bill, according to a new study from the Federal Reserve Bank of New York.
In the first eight months of 2025, 94% of the cost of tariffs was borne by American businesses and consumers, study found.
In September and October, that share slipped to 92%, and in November it fell further to 86% as foreign exporters picked up a larger share of the costs, according to the report.
#Trump#Tariffs
👂More on Trump's Ear ⚠️
Trump's duties are almost entirely paid for by Americans
Almost all the costs of American duties fall on the residents of the United States themselves, and not on foreign manufacturers. This is the conclusion reached by the Kiel Institute of World Economy, having studied about $4 trillion of supplies from the beginning of 2024 to the end of 2025 — WSJ.
According to the researchers' calculations, foreign exporters reduced prices by only 4% and took on the minimum part of the burden. The remaining 96% was paid by American importers and buyers. In fact, duties work as a tax on consumption within the United States, and not as a tool of pressure on foreign businesses.
In 2025, the United States received about $200 billion from duties. The Americans paid almost the entire amount. At first, buyers felt only a part of the price increase - about 20%. The rest of the expenses were temporarily paid by the companies themselves. Later, these costs will be shifted to the buyers, the researchers say.
#Trump#Tariffs
👂More on Trump's Ear ⚠️
Forget retaliation: To cut tariffs President Trump imposed on their country, the Swiss sent a delegation of industry tycoons bearing gifts — a special Rolex desktop clock, a 1-kilogram personalized gold bar, and loads of flattery.
#Trump#Tariffs
👂More on Trump's Ear
US President Donald Trump has made an incredible statement 😮🇺🇸: he wants to pay every citizen of the country $2,000 💵🎁.
The only exceptions are those with high incomes 💼📈.
According to Trump, this will be a "dividend" from the duties he imposed 💬💰.
#Trump#Tariffs
👂More on Trump's Ear
Taxes, duties, and military bases. How Europe Can Respond to Donald Trump
Donald Trump's talk about taking control of Greenland has Europe thinking about how to push back. BILD is throwing out a bunch of ideas, from economic to military, that could put pressure on the Trump administration.
One idea is to go after American tech companies. In Germany, they're talking about a 10% digital tax for companies like Google, Meta, Amazon, Apple, and Microsoft, which make billions in Europe but don't pay much in taxes.
Trade is another option. The EU could either block a new trade deal with the U.S. or slap tariffs on up to 93 billion euros worth of American goods, like bourbon, soybeans, and airplane parts. They're also talking about taxing digital services like cloud storage, streaming, and online ads.
Western countries could even start selling off U.S. government bonds, but experts don't think it'll do much. The U.S. Federal Reserve can just buy them back.
The most extreme idea is to close American military bases in Europe, like Ramstein and Stuttgart. Shutting these down would really hurt the U.S.'s global strategy, but Europe thinks it's too risky, especially with threats on NATO's eastern border.
#EU#Tariffs
👂More on Trump's Ear ⚠️