Что делать если нужно поставить какую-то 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
↗️ Bali raises prices for popular attractions
📰 The authorities of the Balinese district of Badung are revising the fees for visiting popular tourist locations. Ticket and parking prices at temples, waterfalls, and beaches will increase in the near future.
📍Admission prices will increase at the following sites:
Taman Ayun Temple:
• Foreign adults — 50,000 rupiah
• Foreign children — 25,000
Uluwatu Temple (excluding evening kecak):
• Foreign adults — 60,000 rupiah
• Foreign children — 40,000
Pandawa Beach:
• Foreign adults — 25,000 rupiah
• Foreign children — 15,000
Nung Nung Waterfall is also on the list for an increase, with exact prices to be confirmed.
Uniform parking rates are also being introduced:
• 1,000–2,000 rupees for motorcycles
• 2,000–4,000 rupees for cars
• 5,000–10,000 rupees for buses and large vehicles.
🧲 This is being done to replenish the district's budget and finance infrastructure projects.
#places#tourism#Badung@BaliNews
🧹Badung will be cleaned up
Government to tackle litter problem.
🚮 The new regent of Badung, Wayan Adi Arnawa, has made a pledge to keep the top tourist beaches clean and personally participated in a clean-up day on the Jimbaran coast.
I don't want Badung to look shabby because of litter. The government will allocate a special budget to tackle the problem.
ℹ️ Badung includes Changu, Seminyak, Legian, Kuta and the entire Bukit Peninsula. The official said pedestrian walkways are already being built on the beaches and coastal cafes are being renovated to make them more aesthetically pleasing and comfortable.
@BaliNews
#goodnews#places#Badung
📰Illegal structures found in Melasti and scheduled for demolition
🏝 Eight structures in violation of zoning regulations have been identified on Melasti Beach, including beach clubs and cafes that are too close to the ocean, in a protected coastal area, and partially on municipal land. The owners have already been sent repeated official warnings, and the documents have been forwarded to the public order service for further action.
🧐 The administration's approach is now softer than in Balangan: Melasti will be “discussed and carefully studied” rather than “demolished on the spot.”
#places#beaches#Badung@BaliNews
🌊Strong surf damaged the Waterblow attraction in Nusa Dua
📰 High waves damaged the infrastructure of the Waterblow attraction in Nusa Dua. Ticket offices were flooded and the e-ticketing terminal was knocked out of service.
🚫 The site is closed indefinitely; authorities are inspecting the site and agreeing on further steps.
⚠️ Waves of up to 2.5–4 m are expected to continue in southern Bali in the coming days — people are asked to exercise caution near the water.
#weather#places#Badung@BaliNews
🪩 There will be a party at Savaya on Saturday
ℹ️ Building upon her cultural heritage and her musical tastes (the artist grew up listening to artists such as Nina Simone, Bob Marley and Marvin Gaye), AWEN started to produce her unique style of Afro-house.
🧞♀️ It mixed electronic instrumentation with timeless melodies - and a touch of spirituality.
📲 More info and tickets (Rp 600,000) are here.
#wheretogo#parties#Badung@BaliNews
⭐️Electronic music star Boris Brejcha in Bali
📍 Savaya Bali
📆 May 18, 2005
⏰ Doors Open at 1:00 pm
🔞 Entry strictly 21+
🎟 Rp1,350,000
🪩 German DJ Boris Brejcha is known to all lovers of techno and mind-blowing parties. As part of his world tour he will be stopping by Bali.
🔎 More information and tickets here.
@BaliNews
#events#parties#Badung
📰A new art market will open in Bali
🏺 A new art market featuring works by local artisans will open in the village of Bongkasa. The project aims to attract tourists to less popular areas.
👍 In light of the fire that destroyed the market in Ubud, the idea seems like timely support for artisans.
📆 The opening is planned for 2026.
#goodnews#culture#places#Badung@BaliNews
🛕The Pura Luhur Uluwatu temple has begun to be saved from collapsing into the ocean
A serious crack that formed in one of the most sacred places in Bali - the cliff of the temple Pura Luhur Uluwatu - is promised to be fixed by the end of this year. For a long time it frightened the public - from the outside it seemed that the 70-meter cliff is about to collapse into the ocean.
The first phase of work to repair the rift in the cliff is scheduled to be completed in December 2024. The Badung regency government has prepared a budget of Rp 78.6 billion for this purpose.
@BaliNews
#goodnews#places#Badung#Kuta
[SOSIALISASI GEMA CERMAT]
•
https://www.facebook.com/864416113651534/posts/2087373421355791/
•
Sosialisasi GeMa CerMat di Kab. Badung, Bali tanggal 13 Desember 2018, menutup seluruh rangkaian kegiatan Sosialisasi GeMa CerMat tahun 2018 yang diselenggarakan oleh Direktorat Pelayanan Kefarmasian, Kemenkes RI.
Kab. Badung, Bali, menjadi lokasi ke-40 pada tahun 2018, setelah diadakan di Kota Cirebon tanggal 7 Desember 2018.
•
Sosialisasi dihadiri oleh sekitar 270 orang peserta masyarakat dan stake holder terkait di wilayah Kab. Badung, dan 30 orang apoteker sebagai Agent of Change (AoC) GeMa CerMat Kab. Badung. Sehari sebelumnya, tanggal 12 Desember, telah diadakan Pembekalan terhadap apoteker sebagai AoC.
•
Acara pencanangan dan sosialisasi GeMa CerMat di Kab. Badung ini dibuka oleh Direktur Pelayanan Kefarmasian Kemenkes RI, Dinas Kesehatan Prop. Bali, dan Dinas Kesehatan Kota Kab. Badung.
•
Materi paparan tentang GeMa CerMat, DAGUSIBU dan Penggunaan Antibiotik Bijak diberikan oleh Peningkatan Obat Rasional, Erie Gusnellyanti, S.Si, Apt, MKM.
Selanjutnya diadakan simulasi metode edukasi penggunaan obat dengan Cara Belajar Insan Aktif (CBIA).
•
#gemacermat#gemacermatbadung#badung#bali#cerdasgunakanobat#sosialisasigemacermat#aocgemacermat#apotekerindonesia#apoteker#apotekermuda#ppiai @ Badung, Bali, Indonesia