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

Резултати

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

Пребарај: #magnetism

当前筛选 #magnetism清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #649 · 29.08.2025 г., 03:22

🌎 The Zone of Silence in northern Mexico baffles visitors—radios and compasses fail, and strange meteorites have fallen here. Scientists suspect unusual magnetic minerals and local geology disrupt signals, making this desert a hotspot for unexplained natural phenomena. ✨ #mystery⚡#geology⚡#magnetism 👉subscribe Interesting Planet ​

Amazing Geography 🌍

@amazingeo · Post #380 · 16.10.2025 г., 18:31

🌍 Earth has a layered structure: a thin crust, a solid mantle, a liquid outer core, and a solid inner core. The deep core’s movement creates the planet’s magnetic field, vital for life. ✨ #planet⚡#geology⚡#magnetism⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #187 · 06.09.2025 г., 13:12

🌍 Earth’s outer core is made of liquid iron and nickel and creates the planet’s magnetic field. This powerful shield protects life by deflecting harmful cosmic and solar radiation. ✨ #planet⚡#geology⚡#magnetism⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #625 · 11.02.2026 г., 12:31

🌍 Auroras can ripple like curtains or spiral in arcs because solar particles follow Earth's magnetic field lines. Their shifting shapes reveal invisible patterns high above our polar regions. ✨ #aurora⚡#atmosphere⚡#magnetism⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #133 · 28.08.2025 г., 16:12

🌍 Auroras glow when charged particles from the Sun hit Earth's magnetic field, making gases like oxygen and nitrogen light up green, red, and even rare purple or blue in the night sky. ✨ #aurora⚡#magnetism⚡#atmosphere⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Interesting Planet 🌍

@interesting_planet_facts · Post #964 · 25.10.2025 г., 18:11

🌎 Hidden beneath Jupiter’s clouds, the planet’s metallic hydrogen layer creates an enormous magnetic field. This magnetic field is about 20,000 times stronger than Earth’s and traps intense radiation belts. ✨ #Jupiter⚡#planets⚡#magnetism 👉subscribe Interesting Planet 👉more Channels ​

Universe Mysteries 🪐

@cosmomyst · Post #33 · 30.07.2025 г., 05:00

🪐 Spanning more than 300 light-years, a vast radio structure known as the "Orion Spur Radio Arc" weaves through our segment of the Milky Way. Detected by the LOFAR radio telescope, this arc is composed of incredibly energetic electrons spiraling around magnetic fields, revealing a hidden backbone of cosmic magnetism threading through our stellar neighborhood. ✨ #MilkyWay⚡#magnetism⚡#radio 👉subscribe Universe Mysteries

Interesting Planet 🌍

@interesting_planet_facts · Post #708 · 08.09.2025 г., 00:22

🌎 The mysterious Whistler waves are very low-frequency radio signals generated by lightning. They travel along Earth's magnetic field lines and can be converted to eerie whooshing or whistling sounds when played back as audio. These signals were first recorded by radio operators during World War I. ✨ #lightning⚡#magnetism⚡#radio 👉subscribe Interesting Planet ​

Universe Mysteries 🪐

@cosmomyst · Post #270 · 14.09.2025 г., 13:11

🪐 In the constellation Lynx lives an unusual star known as HD 45166, which has an incredibly strong magnetic field—about 43,000 times greater than Earth’s. This rare "magnetized helium star" shrouds itself in a thick, fast-moving wind of gas, and its unique magnetic properties provide astronomers with a rare look at how intense magnetism can shape the life and appearance of stars. ✨ #unusualstars⚡#magnetism⚡#astronomy⚡#nasa⚡#galaxy⚡#stars⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries ​

Amazing Geography 🌍

@amazingeo · Post #491 · 03.12.2025 г., 12:31

🌍 Earth’s core spins slightly faster than its surface, a phenomenon called “super-rotation.” This hidden motion helps maintain our magnetic field, vital for navigation and life. ✨ #planet⚡#core⚡#magnetism⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #75 · 19.08.2025 г., 03:12

🌍 Earth's magnetic field acts like a protective shield, deflecting harmful solar wind and cosmic rays. This invisible force helps preserve our atmosphere and supports life on the planet. ✨ #magnetism⚡#protection⚡#atmosphere⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Universe Mysteries 🪐

@cosmomyst · Post #194 · 26.08.2025 г., 20:11

🪐 In the constellation Monoceros, the star HD 45166 is an unusually magnetic massive star with a surface magnetic field nearly 43,000 times stronger than Earth's. This extreme magnetism shapes the flow of gas around the star, producing powerful outflows and making HD 45166 a rare laboratory for studying the effects of magnetism on stellar evolution. ✨ #stars⚡#magnetism⚡#Monoceros⚡#nasa⚡#galaxy⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries ​

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