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

Резултати

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

Пребарај: #exoplanet

当前筛选 #exoplanet清除筛选
Universe Mysteries 🪐

@cosmomyst · Post #20 · 29.07.2025 г., 22:51

🪐 Nearly 400 light-years from Earth, the bizarre exoplanet HD 189733b endures violent weather, with winds reaching up to 8,700 kilometers per hour. Its atmosphere contains silicate particles, causing glass rain that whips sideways at supersonic speeds, giving the planet an eerie, cobalt-blue hue. ✨ #exoplanet⚡#weather⚡#glass 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #30 · 30.07.2025 г., 03:51

🪐 The peculiar exoplanet GJ 1214b, orbiting a red dwarf 48 light-years away in the constellation Ophiuchus, is shrouded in a thick, steamy atmosphere dominated by water vapor. Observations suggest that this "mini-Neptune" may possess a vast, deep ocean beneath its clouds, making it a striking example of a possible water-world beyond our solar system. ✨ #exoplanet⚡#waterworld⚡#atmosphere 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #180 · 24.08.2025 г., 00:11

🪐 Exoplanet WASP-12b, about 1,400 light-years away in the constellation Auriga, is a giant planet so close to its star that its atmosphere is being stripped away, creating a glowing, comet-like tail. This tidal distortion makes WASP-12b egg-shaped rather than round, showing how extreme gravity can reshape giant planets when they orbit near their stars. ✨ #giantplanets⚡#exoplanet⚡#gravity⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries ​

Universe Mysteries 🪐

@cosmomyst · Post #71 · 02.08.2025 г., 20:11

🪐 The exoplanet KELT-9b, orbiting a star about 670 light-years away in Cygnus, is one of the most extreme worlds ever found—its dayside temperatures soar above 4,000°C, hotter than some stars. Metal atoms like iron and titanium are vaporized in its atmosphere, creating a blistering, glowing layer of gas that defies what we imagine for planets outside our solar system. ✨ #exoplanet⚡#extremes⚡#heat⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #87 · 06.08.2025 г., 00:11

🪐 Far from Earth, the exoplanet COROT-7b endures some of the most extreme conditions known: it orbits its star so closely that its surface reaches about 2,000°C, hot enough to melt rock. Scientists believe this heat turns the planet’s rocky crust into a vast, bubbling “lava ocean,” creating a world where rock vaporizes into the atmosphere and rains down as pebbles. ✨ #exoplanet⚡#extremes⚡#lava⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #52 · 31.07.2025 г., 16:11

🪐 Orbiting the red dwarf LHS 3844, the exoplanet LHS 3844b is a rocky world with no detectable atmosphere and a surface thought to resemble volcanic basalt, much like the Moon’s dark maria. The planet's dayside bakes at over 770°C while its nightside plunges into perpetual darkness, creating a world divided between scorching light and endless night. ✨ #exoplanet⚡#extremes⚡#basalt⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #159 · 20.08.2025 г., 00:11

🪐 Scientists have identified the exoplanet Gliese 581d, orbiting a red dwarf star about 20 light-years away, as one of the earliest potentially habitable worlds outside our solar system. Gliese 581d lies within its star's habitable zone, where temperatures might allow liquid water to exist, making it a key target in the search for life beyond Earth. ✨ #exoplanet⚡#habitability⚡#water⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #133 · 14.08.2025 г., 20:11

🪐 Deep in the constellation Scorpius, the star KELT-9 stands out as the hottest known main-sequence star with a planet, blazing at over 10,000°C on its surface. Its intense ultraviolet radiation is so strong that it causes the atmosphere of its planet, KELT-9b, to evaporate away, carving one of the most dramatic examples of a planet literally being stripped by its parent star. ✨ #unusualstars⚡#scorpio⚡#exoplanet⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #65 · 02.08.2025 г., 13:12

🪐 Just 39 light-years away, the exoplanet TRAPPIST-1e circles its cool red dwarf star in the habitable zone, where temperatures might allow liquid water. Scientists have found that TRAPPIST-1e has a rocky surface and, unlike some of its neighbors, could have the right conditions for life as we know it. ✨ #exoplanet⚡#habitability⚡#TRAPPIST1e⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #51 · 31.07.2025 г., 13:11

🪐 The white dwarf WD 1145+017 in the constellation Virgo is surrounded by a cloud of dust and debris from a disintegrating minor planet. As the remains slowly spiral in, transit observations reveal dips in starlight—evidence of a cosmic demolition that offers a real-time look at how planetary systems can be torn apart at the end of a star's life. ✨ #whiteDwarf⚡#exoplanet⚡#debris⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #58 · 01.08.2025 г., 20:11

🪐 Gliese 436b, a Neptune-sized exoplanet in the constellation Leo, is wrapped in a scorching atmosphere where temperatures soar above 800°C. Strangely, its elongated, comet-like tail of evaporating hydrogen trails tens of millions of kilometers behind, evidence of atmospheric escape driven by its star’s relentless heat and radiation. ✨ #exoplanet⚡#evaporation⚡#Leo⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #459 · 26.10.2025 г., 22:21

🪐 The James Webb Space Telescope has detected carbon dioxide on the exoplanet HD 189733b, a giant world 64 light-years away in the constellation Vulpecula. This is the first time carbon dioxide—a common gas on Earth—has been firmly identified in the atmosphere of an exoplanet, using Webb’s powerful infrared instruments to reveal details about the planet’s chemistry and hint at how its formation differs from giant planets in our own solar system. ✨ #webb⚡#exoplanet⚡#atmospheres⚡#discoveries⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​