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

Резултати

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

Пребарај: #urbandesign

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

@URASingapore · Post #1083 · 20.12.2024 г., 10:00

Does this vibrant walkway look familiar? Once just a canal, it's now a bustling pedestrian mall along Orchard Road! Open spaces, art installations, and alfresco dining showcase how urban design transforms infrastructure into lively community hubs. Uncover more behind-the-scenes stories about how urban design has shaped Singapore over the last 50 years 👉🏻go.gov.sg/UDPlanstoRealityTG #UrbanDesign

Hashtags

URA Singapore

@URASingapore · Post #919 · 03.08.2024 г., 02:00

🤔 Have you seen this staircase at Upper Thomson Road on your social media feed? More than just a photogenic spot, it is the result of a community effort led by Joanne Teh, a resident at Yew Lian Park, who wanted to make the pathway safer and more attractive for everyone to use and enjoy. If you have an idea to enhance and enliven the spaces around you, apply to get up to $20,000 from the Lively Places Fund for your initiatives! Find out more 👉go.gov.sg/LivelyPlacesFundTG #UrbanDesign#LivelyPlacesFund

URA Singapore

@URASingapore · Post #910 · 24.07.2024 г., 10:00

Singapore’s hot weather can be a bother if you take a stroll at Marina Bay. But with our solar-powered breeze shelters strategically placed along the promenade, you don’t need no Oppas to shelter you from the heat! 🌬 #UrbanDesign#DiscoverSingapore#MarinaBay

URA Singapore

@URASingapore · Post #905 · 11.07.2024 г., 10:30

A bunch of postcards just arrived in the mail for you! 💌 We’re working on a Recreation Master Plan to make way for more leisure opportunities. For the Central Area of Singapore, there are plans to enhance the attractiveness of the community space at Sultan Gate, improve the walk-cycle connectivity along the Inner Ring Corridor and more! Want to help shape these spaces and other recreational spots in this region? Share your best ideas with us here: 👉go.gov.sg/CentralAreaRecreTG #DMP2025#RecreaMP#ExploreSingapore#Recreation#UrbanDesign#SpaceForOurDreams

URA Singapore

@URASingapore · Post #1428 · 06.12.2025 г., 10:00

Love the vibes at Holland Village? We do too 🙌 From low-rise buildings to continuous walkways and elegant signages, find out how we’re retaining the unique charm and familiar identity of the area through thoughtful planning and design. #HollandVillage#ExploreSingapore#UrbanDesign#IdentityNode#SGHeritage

URA Singapore

@URASingapore · Post #947 · 12.09.2024 г., 04:15

Can you picture a car-lite future for Singapore? With more cycling paths being built, it could soon be a reality! The Bishan-to-City (B2C) Link is one of the pathways made possible by planners like Syafie, along with feedback from citizens like you, to make the island more connected and accessible for everyone. Watch on to learn more about his role and why he loves it. Want to shape our city too? Explore career opportunities with URA now 👉http://go.gov.sg/URA-CareersSyafieTG Also, learn more about our efforts to create a car-lite and sustainable city on our free guided community tours: http://go.gov.sg/ura-wcfd24 #UrbanDesign#URASingapore#DiscoverSingapore#Hiring#UrbanPlanning#WCFDsg#WorldCarFreeDay

The Shanghai Lingang Special Area master plan. Design: Ennead Architects Location: Shanghai, China Ennead Architects has designed the Shanghai Lingang Special Area master plan (a new hub for global commerce) around the central axis that defines the Dishui Lake district in Shanghai. One of the key features of the Shanghai Lingang Special Area will be “The Ring”. This circular, cantilevered observation deck, and museum will afford 360-degree views of nearby Dishui Lake, Shanghai and the Pacific Ocean. The two towers flanking the Ring (The Tower Waterfall and Tower Rhomboid) are designed to become two of the most easily recognizable features of the new business district. Similar in scale, the towers have distinct identities. #Architecture#arch_shovel#NewsArchitecture#News#Shanghai#China#Masterplan#CityPlanning#OfficeBuilding#CommercialArchitecture#UrbanDistrict#UrbanDesign