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

Резултати

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

Пребарај: #recreation

当前筛选 #recreation清除筛选
URA Singapore

@URASingapore · Post #871 · 14.06.2024 г., 09:31

‘❌’ always marks the spot. Can you decipher the next location of our roving exhibition for the Recreation Master Plan? 💎⁣ Give this post a 👍 if you've figured it out! Still in the dark? Then stay tuned for more updates 😉 #DMP2025#SpaceForOurDreams#RecreaMP#Recreation

URA Singapore

@URASingapore · Post #780 · 17.04.2024 г., 10:06

Westies, check out these up-and-coming spaces that will make it easier to rest and relax! 😋 As part of the Recreation Master Plan, we are exploring ways to bring recreation closer to your doorstep and to develop a connected network of parks, natural green spaces, and waterways. Visit our first two roving exhibitions to explore future plans for the West: 1️⃣ 14 – 19 Apr: Westgate 2️⃣ 21 – 28 Apr: Senja-Cashew Community Centre 👉go.gov.sg/ConnectedtoPlayTG Photo credit: Housing Development Board [1], National Parks Board [2], Land Transport Authority [3] and JTC Corporation [4] #DMP2025#SpaceForOurDreams#RecreaMP#Recreation

URA Singapore

@URASingapore · Post #774 · 14.04.2024 г., 02:00

When it comes to living well, it’s essential to have places for play and recreation in our city. 🏋️‍♂️🚣‍♀️🎬 Planning these spaces to support active and fulfilling lives has always been a key aspect of our plans. Check out such upcoming spots in the West, with more coming your way in the Recreation Master Plan! Visit our first roving exhibition to share your feedback on proposals and recreation plans for the West. Find us at: Westgate from 14 – 19 April and Senja-Cashew Community Centre from 21 – 28 April 👉go.gov.sg/ExploreWestTG #DMP2025#SpaceForOurDreams#Recreation#RecreaMP

URA Singapore

@URASingapore · Post #767 · 05.04.2024 г., 10:01

Westies, do you recognise these places? 😉 Here’s the perfect recreation spot for each of your favourite activities! 🙌 Planning ahead for the long-term has allowed us to weave play and leisure into our city fabric. With the Recreation Master Plan, we’re creating more recreational opportunities by tapping on our green, blue, and everyday spaces. Want to know what’s in store? Visit our first roving exhibition for a sneak peek into future plans for the west, from 14 – 19 April. 👉go.gov.sg/BestinWestTG React with a ❤️ if you’re excited to check out the exhibition! #DMP2025#SpaceForOurDreams#Recreation#RecreaMP

URA Singapore

@URASingapore · Post #897 · 02.07.2024 г., 10:33

If you could shape the future of the North, with all its potential, what would it look like?⁣ 🤔 Bring your best ideas to the roving exhibition for the Recreation Master Plan and help co-create exciting recreational offerings to be enjoyed and experienced by Singaporeans from all walks of life.⁣ Event deets 👇⁣ 📌Canberra Plaza⁣ 🗓️6 – 14 July⁣ Find out more here 👉go.gov.sg/NorthRecrePlansTG #ExploreSingapore#RecreaMP#DMP2025#Recreation#SpaceForOurDreams

URA Singapore

@URASingapore · Post #879 · 22.06.2024 г., 04:08

From a wealth of greenery to inland waterways, the North-East region is home to many active lifestyle amenities and hidden gems for recreation💎 Visit our Recreation Master Plan exhibition and share your best ideas on how we can enhance these spaces for more recreational opportunities! 📍One Punggol 📆 22 - 30 June You can also submit them via the FormSG link here 👉go.gov.sg/NorthEastRecrePlansTG #DMP2025#SpaceForOurDreams#RecreaMP#Recreation#ExploreSingapore

URA Singapore

@URASingapore · Post #851 · 29.05.2024 г., 10:00

Got a big appetite for fun? Check out the multitude of recreational opportunities we’re creating through the Recreation Master Plan! 👆 Swing by to see and share ideas for these exciting recreation plans! 📍 VivoCity 📆 25 May – 2 June 2024 📍 Kallang Wave Mall 📆 8 – 16 June 2024 See ya there 👋 Find out more at: go.gov.sg/CentralRecrePlansTG #DMP2025#SpaceForOurDreams#RecreaMP#Recreation#ExploreSingapore

URA Singapore

@URASingapore · Post #842 · 22.05.2024 г., 04:05

So, what’s on the menu in the Central Region? Well, we have quite a spread 😋 Here’s a sample of the recreation plans bringing you more leisure opportunities in this part of Singapore 🙌 Learn all about the new marine park at the Southern Islands and other exciting developments in Kallang, Southern Ridges and more at our roving exhibitions for the Recreation Master Plan! Visit the exhibition at: 📍 VivoCity 📆 21 May – 2 June 2024 Kallang Wave Mall 8 – 16 Jun 2024 #DMP2025#SpaceForOurDreams#RecreaMP#Recreation#ExploreSingapore

URA Singapore

@URASingapore · Post #833 · 14.05.2024 г., 10:08

Where to next? ✈️ To the East side we go! 😁 Have ideas to create more recreational opportunities around our island? Help us put together an itinerary of leisure options that we can all enjoy in the future through the Recreation Master Plan 👉go.gov.sg/EastRecrePlansTG #DMP2025#SpaceForOurDreams#RecreaMP#Recreation#ExploreSingapore

URA Singapore

@URASingapore · Post #826 · 11.05.2024 г., 04:49

Catch flights, not feelings - and step into the future with us ✈️ Swipe ➡️ to some of the future recreational developments in the East that’ll bring you even more leisure opportunities. Be sure to catch our Recreation Master Plan exhibition at: 📍 Bedok Town Square 📆 11 – 19 May 2024 👉 Find out more at: go.gov.sg/RecreTripTG #DMP2025#SpaceForOurDreams#RecreaMP#Recreation#ExploreSingapore

URA Singapore

@URASingapore · Post #814 · 07.05.2024 г., 04:23

Would you like to see more outdoor gyms? 🏋️ Well, one Westie certainly does 🙌 At our recent Recreation Master Plan roving exhibition, we caught up with some of you 👀 who shared about the new recreational spaces you’re most looking forward to. These exhibitions will be roving to a location near you from now till July. Visit us and share your recreational ideas for your ‘hood! The next stop will be at Bedok Town Square from 11 - 19 May! 👉 Find out more on the Recreation Master Plan here: go.gov.sg/EverydayVoicesTG #DMP2025#SpaceForOurDreams#RecreaMP#Recreation#ExploreSingapore

URA Singapore

@URASingapore · Post #811 · 03.05.2024 г., 10:01

Did you manage to catch our last Recreation Master Plan exhibition in the West? 🧐 If not, come join us at our upcoming one in the East! React to this post with a 👍 if you’ve figured out just where it’s being held 😄 Still in the dark? Then stay tuned for more information soon 😉 #DMP2025#SpaceForOurDreams#RecreaMP#Recreation#ExploreSingapore

12
ПретходнаСтраница 1 од 2Следна