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

Резултати

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

Пребарај: #luxurysuv

当前筛选 #luxurysuv清除筛选
Auto Life

@revheadcrypto · Post #127 · 19.07.2024 г., 09:40

💡The Cadillac Escalade has been updated in the USA ✨ The Escalade features new lighting technology, an emblem with backlight, and in the V-Series and Premium Luxury Platinum trims, it also has ambient lighting around the grille. 24-inch wheels are now available as an option. ♨️ The interior boasts a 55-inch display across almost the entire width of the front panel. Optionally available are extremely comfortable second-row seats with massage, dual wireless chargers, and two 12.6-inch screens. 🚘 All trims, except the base Luxury, come with adaptive Magnetic Ride Control 4.0 suspension and a heads-up display. The signature Super Cruise "autopilot" feature is now included in the base model at no extra charge. ⚙️ Under the hood, the 6.2-liter V8 with 420 hp and the 682-hp supercharged V8 of the same volume are retained. Sales will start at the end of the year. #CadillacEscalade#LuxurySUV#Upgrade#Auto

Auto Life

@revheadcrypto · Post #411 · 31.08.2024 г., 10:47

🚗✨Electric Range Rover Unveiled!✨🚗 📸 Check out the latest photos of the all-electric Range Rover without camouflage! 🔍Design: It features only subtle design differences from its petrol counterpart. 📅Pre-orders: While specifications are still under wraps, the demand is skyrocketing! Over 41,000 people are already on the waiting list! Are you excited about this new electric beauty? 💚⚡ #ElectricRangeRover#SustainableDriving#LuxurySUV#CarEnthusiasts#Auto

Auto Life

@revheadcrypto · Post #324 · 16.08.2024 г., 19:05

🌟🚗 Introducing the Genesis GV90! 🚗🌟 Get ready for the flagship electric crossover from Genesis, set to debut this October! 🎉✨ Built on the innovative eM platform, an evolution of the E-GMP architecture, the GV90 promises an impressive 113 kWh battery that offers a remarkable range of up to 800 km!🔋🌍 With its luxurious design and advanced features, the GV90 will compete with premium full-size SUVs like the Range Rover. 🏞️👑🚀 #GenesisGV90#ElectricCrossover#LuxurySUV#eMPlatform#Auto🌐🔋✨

Auto Life

@revheadcrypto · Post #259 · 07.08.2024 г., 11:59

🚗✨ Exciting news from BMW! The new extended X3 is here, specially designed for the Chinese market! 🇨🇳 With a wheelbase stretched by 110 mm to an impressive 2975 mm (just like the European BMW X5), the overall length now reaches 4865 mm! 📏 Available in two versions: 25L and 30L, both equipped with an 8-speed automatic transmission and a powerful 2.0L turbo engine. Choose between 190 hp & 310 Nm or 258 hp & 400 Nm! 💪🔥 #BMW#X3#LuxurySUV#China#CarNews#Automotive#Innovation#Auto🚘🌟

Auto Life

@revheadcrypto · Post #423 · 02.09.2024 г., 13:52

▎🚘 Introducing the All-New Audi Q5! The next generation of the Q5 has arrived, now built on the PPC (Premium Platform Combustion), shared with the recently unveiled Audi A5. The design is completely new, yet resonates with the familiar aesthetic of Audi’s electric models. 🎮Inside the Cabin: Featuring three stunning displays on the central panel, the media system runs on Android OS. The compact gear selector enhances the sleek design, while physical climate control buttons have been eliminated for a more modern feel. ⚡️Power & Performance: In Europe, all Audi Q5 engines will come equipped with the MHEV Plus mild-hybrid system, featuring a 24 hp electric motor and a compact battery. The base versions will offer both petrol and diesel engines with a 2.0-liter capacity, delivering 204 hp (340 Nm) and 204 hp (400 Nm), paired with a seven-speed dual-clutch transmission. The powerful 3.0-liter V6 in the Audi SQ5 boasts an impressive 376 hp and 550 Nm of torque. 🗓️Availability: The new Q5 will hit European markets in Q1 2025, with pre-orders already open, starting from €52,300 to €82,900. ▎🔥 Get ready to experience luxury like never before! #AudiQ5#NewGeneration#LuxurySUV#Audi#Innovation#MHEV#Auto

Auto Life

@revheadcrypto · Post #510 · 20.09.2024 г., 21:41

🚗✨ Exciting news for luxury SUV enthusiasts! The new Range Rover Sport has been stunningly upgraded by Mansory! 🔧 The front bumper features a sleek splitter with stylish end caps and custom air vent overlays. The body kit includes new side skirts and a diffuser that perfectly complements the bespoke exhaust tips. 🔥 The Range Rover Sport SV boasts an alternative hood, unique inserts around the grille, and exclusive wheels available in 23 or 24 inches! 💰 While the price for these upgrades hasn't been disclosed, the demo model is already up for sale! #RangeRoverSport#Mansory#LuxurySUV#CarEnthusiast#CustomCars#AutoDesign#LuxuryLifestyle#Auto