TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #210 · 3 фев.

Что делать если нужно поставить какую-то 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

Резултати

Пронајдени 3 слични објави

Пребарај: #climatechanges

当前筛选 #climatechanges清除筛选
Trump's Ear

@trumpsear_tg · Post #1802 · 20.11.2025 г., 14:59

The White House's climate policy may lead to 1.3 million deaths 🚨🔥, an analysis by ProPublica and the Guardian shows that Donald Trump's decisions, which return the country's oil, gas and coal production to previous volumes and lift climate restrictions, will increase emissions and lead to 1.3 million additional deaths from heat in the future 😱⛏️, writes the Guardian. The poor and hot countries of Africa and South Asia will bear the brunt. 🌍🔥 Scientists are already seeing an increase in mortality. In the United States, the number of deaths due to heat has increased by more than 50% since 2000. ☀️📈 In India and Pakistan, heat above 48 degrees is already causing deaths in towns and villages. 🔥🏞 The elderly, children, and those who work on the streets suffer more than others. 👵👶🏃‍♂️ The authors of the analysis believe that the increase in emissions in the next ten years will worsen the situation. 🗣💨 Researchers say that the United States accounts for a fifth of the world's emissions, but it will see only a small increase in deaths. 🇺🇸🌍 The regions where people already live in extreme heat will suffer the most. #Trump#ClimateChanges 👂More on Trump's Ear

Trump's Ear

@trumpsear_tg · Post #2303 · 25.03.2026 г., 20:05

The Trump administration announced it will pay nearly $1 billion to French energy giant TotalEnergies in exchange for the company abandoning plans to build offshore wind farms in the Atlantic Ocean and instead pursue fossil fuel projects in the US. ⚡️ The current administration has thrown up roadblocks at every turn for offshore wind projects; a type of energy that President Donald Trump has personally reviled for years. After trying and failing to block construction on more mature projects, this announcement is the first sign of a new strategy: The federal government is paying to stop wind farms before they begin. 🌬 Last year, the Trump Interior Department took the step of stopping the approval of federal permits for renewable energy projects, a move that effectively killed offshore wind projects in early development. Monday’s deal builds on that, by trying to ensure companies can’t continue building under a future administration friendlier to offshore wind. 🏛 The government is paying back TotalEnergies for federal leases it purchased under the Biden administration to develop two offshore wind farms off the coasts of New York and North Carolina. The Justice Department will use nearly $1 billion in taxpayer funds to reimburse the company for money it spent to purchase leases under the Biden administration. 💰 Together, those two projects could have generated more than 4 gigawatts of electricity for US households and businesses, according to developers. ⚡️ #Energy#ClimateChanges 👂More on Trump's Ear ⚠️

Trump's Ear

@trumpsear_tg · Post #2147 · 13.02.2026 г., 14:59

Trump canceled a key point of the US climate policy, calling greenhouse gases harmless. US President Donald Trump has achieved the cancellation of the decision on which the American climate policy has been based since 2009. The U.S. Environmental Protection Agency (EPA) has invalidated the Obama-era conclusion that carbon dioxide and other greenhouse gases pose a threat to public health and well-being. It was on this norm that the key climate restrictions under the Clean Air Act were based, from emission limits for cars to requirements for power plants and industry. Trump and EPA chief Lee Zeldin called the move "the largest deregulation in American history." According to Trump, the previous rules were "disastrous," hurting the auto industry and "inflating prices for consumers." Environmentalists call the cancellation a historic setback and the biggest blow to the United States' ability to combat climate change. #Trump#Ecology#ClimateChanges 👂More on Trump's Ear ⚠️