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

Резултати

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

Пребарај: #gambella

当前筛选 #gambella清除筛选
Addis Standard

@addisstandardeng · Post #21176 · 24.01.2026 г., 10:23

#Ethiopia: Shooting near #Gambella Grand Hotel leaves one dead, injures another; city administration imposes movement restrictions One person was killed and another injured in a shooting near the Gambella Grand Hotel on Thursday afternoon, disrupting daily life in the city and prompting the Gambella City Administration to impose temporary restrictions on movement and public services, according to a senior regional official and a local resident who spoke to Addis Standard. A senior regional official, who requested anonymity for security reasons, said the shooting occurred at around 1:05 p.m. while Tabots—sacred religious icons—were being escorted back to a local church following a religious ceremony. According to the official, most of the procession had already passed the area near the hotel when the incident took place, affecting only a few people at the back of the escort. “The target wasn’t the crowd,” the official said. “It appears the individual who.... Read more: https://addisstandard.com/?p=54727

Addis Standard

@addisstandardeng · Post #22165 · 02.05.2026 г., 12:41

News: Media Authority Board Chair praises new AI-driven integrated system’s role in enforcing accountability, oversight Speaking at the inauguration on 1st of May, Ambassador Redwan Hussein, Director General of the National Intelligence and Security Service (NISS) who is also Chairperson of the EMA Board, described the system as a decisive break from opaque and manual practices. Furthermore, the new platform will introduce full traceability of permits and compliance, he said. “We will know to whom we gave a permit and when it expires. Evidence will be generated upon expiry.” He highlighted its contribution to address cases including “someone who takes a permit to work in #Addis_Abeba will no longer be found working at the edge of #Gambella in the middle of the night, an issue we faced under the old system.” https://addisstandard.com/?p=56731

Addis Standard

@addisstandardeng · Post #21457 · 19.02.2026 г., 16:27

#Gambella Region authorities say measures taken against #security members following recent unrest Authorities in the Gambella Region say legal and administrative actions have been taken against police personnel following recent security crises in the region, including disciplinary measures, retraining programs, and court proceedings targeting alleged misconduct within the force. According to the Gambella Police Commission, regular police and riot control units were sent to the Dalol Central Command Training Center for training as part of broader reforms initiated after the recent security incidents. Police members who did not attend the training underwent physical evaluations and disciplinary review sessions that included internal assessments. Separate court rulings in Gambella city gave verdicts on cases involving civilians and former officers accused of wearing unauthorized police uniforms and concealing government weapons. https://addisstandard.com/?p=55245

Addis Standard

@addisstandardeng · Post #21412 · 16.02.2026 г., 08:20

News: Poor market functionality persists across #Ethiopia despite slight easing of household costs More than half of assessed #markets across Ethiopia showed poor functionality between late December 2025 and early January 2026, underscoring continued supply disruptions despite a slight decline in household expenditure costs, a recent Joint Market Monitoring Initiative factsheet indicates. According to the report, more than half (52%) of assessed markets across Ethiopia were found to have poor functionality, with the highest prevalence reported in #Gambella (100%), #Amhara (74%), #Afar (67%), and #Oromia (63%). The deterioration was largely linked to ongoing conflict, particularly in Gambella, Amhara, and Oromia, which disrupted trade routes and restricted trader movement. Additional pressure came from fuel shortages and rising transportation costs that constrained commodity supply and weakened market integration. Read more: https://addisstandard.com/?p=55200

Addis Standard

@addisstandardeng · Post #21917 · 02.04.2026 г., 14:02

News: #State_Department issues ‘Do Not Travel’ warning for five regions of #Ethiopia amid heightened security risks The U.S. Department of State has issued a Level 4 “Do Not Travel” warning for several regions in Ethiopia, citing escalating security threats including armed conflict, crime, and kidnapping. In its latest travel advisory update released on April 1, the department named #Tigray, #Afar, #Amhara, #Gambella, and #Benishangul Gumuz among areas facing heightened risks, urging U.S. citizens to avoid travel to these regions entirely. The advisory stated that these areas are affected by ongoing armed conflict, political and ethnic violence, and widespread insecurity, with conditions that can deteriorate rapidly without warning. Beyond the Level 4 regions, the State Department maintained Ethiopia under a Level 3 “Reconsider Travel” advisory overall, pointing to broader concerns including unrest, terrorism, landmines, and communication disruptions across Read more: https://addisstandard.com/?p=56258

Addis Standard

@addisstandardeng · Post #21287 · 03.02.2026 г., 07:48

#Ethiopia: MP Abebaw challenges peace talks with splinter armed groups Member of Parliament Dr. Abebaw Desalew of the National Movement of Amhara (#NaMA) has questioned Prime Minister #Abiy Ahmed over the federal government’s approach to peace negotiations and regional security, warning that talks with what he described as “splinter groups” have failed to bring tangible improvements on the ground. Dr. Abebaw raised the concerns during the 10th Regular Session of the 5th Year of the 6th Term of the House of Peoples’ Representatives (#HoPR), where MPs questioned the Prime Minister on the government’s six-month performance report. He said Ethiopia continues to face a pervasive lack of peace, particularly in conflict-affected regions including #Amhara, #Oromia, #Tigray, and #Gambella, while noting that serious human rights violations are also reported in regions without active armed conflict. “Even in areas not experiencing open conflict, members from the... Read more: https://addisstandard.com/?p=54927