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

Резултати

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

Пребарај: #sgclean

当前筛选 #sgclean清除筛选
REACH

@reachsg · Post #98 · 17.02.2020 г., 03:03

[Sent by Gov.sg – 17 Feb] SG Clean - COVID-19 is transmitted primarily through droplets. To fight this outbreak, we need to look after our personal hygiene, AND keep Singapore clean. - A clean environment will help stop community transmission of COVID-19 7 good habits 1. Keep premises clean and pest-free 2. Return trays, keep tables clean 3. Keep toilets clean and dry 4. Wash hands regularly with soap 5. Take temperature, see doctor if unwell, stay home 6. Use tissue when sneezing or coughing 7. Bin litter and soiled tissue NEA stepping up: - Inspection of public toilets and other public places - Enforcement against spitting and littering - Adoption of SG Clean quality mark, to ensure high level of cleanliness More on #SGClean: go.gov.sg/sgclean More hygiene tips: go.gov.sg/getserious

Hashtags

NEA Singapore

@NEASingapore · Post #21 · 13.03.2020 г., 07:44

More than 5,000 premises have been certified #SGClean since the campaign launch on 16 Feb 2020! But what does this mean? Premises with the SG Clean quality mark have high levels of cleaning and hygiene standards. Go to sgclean.gov.sg for a list of places that are certified SG Clean.

Hashtags

NEA Singapore

@NEASingapore · Post #24 · 18.03.2020 г., 02:35

#DidYouKnow that Chomp Chomp Food Centre’s unique name originated from its Teochew name, Tiong Tiong, which means loyalty and righteousness? If you’ve visited Chomp Chomp recently, you may have seen the SG Clean quality mark signalling the hawker centre’s high level of cleaning and hygiene standards. The full list of certified SG Clean places is available at sgclean.gov.sg #SGClean#OurHawkerCentres

NEA Singapore

@NEASingapore · Post #182 · 08.05.2021 г., 01:15

Are we practising #GoodHygieneHabits when we’re out and about? From washing our hands regularly to using a serving spoon and avoiding double-dipping, let’s not forget these practices when dining with family and friends. #SGClean

NEA Singapore

@NEASingapore · Post #29 · 29.03.2020 г., 05:24

Meet our SG Clean Ambassadors! Sharing a common passion to make #SGClean a way of life, our #SGCleanAmbassadors will help drive the adoption of good personal habits and social norms. They will encourage patrons to return their trays and keep tables clean, and guide them on safe distancing measures to #FightCOVID19 and other infectious diseases. Interested to join the SG Clean Ambassadors Network? Sign up at http://go.gov.sg/sgcleanambassadors

NEA Singapore

@NEASingapore · Post #18 · 21.02.2020 г., 04:30

“We are the first line of defence in ensuring that our patrons dine with peace of mind. We have intensified our cleaning efforts to ensure the cleanliness of the toilets, food trays, cutlery, tables and chairs. One major change to our daily work is the use of four different cloths, each for a different purpose. With these enhanced measures, we hope to reassure the public and encourage them to continue dining here.” – Mr Deji Pravin, Nick Cleaning Services Pte Ltd, Hawker Centre @ Our Tampines Hub #FightCOVID19#SGClean#SGUnited#SingaporeTogether

NEA Singapore

@NEASingapore · Post #69 · 20.06.2020 г., 03:30

We are all looking forward to dining in again at our favourite places. Let’s not forget good dining habits at #OurHawkerCentres to mitigate the spread of COVID-19! #BinOurTissues & #ReturnOurTrays, to keep the table clean for the next user and reduce the risk of disease transmission to cleaners and other members of the public. Eat from your tray, and don’t leave behind soiled tissues or wet wipes on dining tables. #FightCOVID19#SGClean

NEA Singapore

@NEASingapore · Post #15 · 15.02.2020 г., 02:46

We continue to press on in the fight against the COVID-19! NEA has been providing guidance to operators of food establishments, including stallholders at #OurHawkerCentres, to maintain high standards of hygiene and cleanliness to safeguard public health. You can do your part by practising the 7 Habits of Good Public Hygiene! Together we can overcome! #FightCOVID19#SGClean#SingaporeTogether#SGUnited https://youtu.be/t19szcAGw-U

NEA Singapore

@NEASingapore · Post #67 · 17.06.2020 г., 12:55

Don’t leave your used tissues or wet wipes behind when dining at #OurHawkerCentres! It is important to dispose of used tissues or wet wipes which can be highly contaminated, to #FightCOVID19, especially as we resume our activities gradually. From 19 Jun when dining-in resumes, Safe Distancing Ambassadors at hawker centres and coffeeshops will be on hand to remind patrons to be socially responsible and observe personal hygiene. Let’s all do our part to keep ourselves and those around us safe. https://go.gov.sg/nea17jun20-hygieneathcs-toilets #BinOurTissues#ReturnOurTrays#SGClean#KeepSGClean