@levit_world · Post #1706 · 24.10.2024 г., 10:11
#Noob-Saibot_style
Hashtags
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
Пребарај: #noob
@levit_world · Post #1706 · 24.10.2024 г., 10:11
#Noob-Saibot_style
Hashtags
@PensivePost · Post #4837 · 28.01.2021 г., 09:14
A heart that flickers, a tear that glimmers and an ink that spills. It's really not that deep, you're just too shallow. #review#noob#poetry
@PensivePost · Post #5170 · 06.05.2021 г., 06:10
I knew a girl who liked to draw, Pictures for only her eyes. She was more artistic late at night. Her drawings were different, No paper, No pen. But she needed a bandage, And wore long sleeves twenty-four/seven. We stood by the river, Under the stars, When she rolled up her sleeves And showed me her scars. She felt embarrassed and stared at her shoe. Then I rolled up my sleeves and whispered, "I draw too." #review#yourreview#noob
Hashtags
@PensivePost · Post #4753 · 17.01.2021 г., 14:31
Honesty for one, behold my love. I'll come in your dreams, For every night that I'm gone. Honesty for one, Behold my Love. #review#noob#prose Author's note: This might not make sense because: There's a song that I only remember by the deep voice of the singer, the melody and the vague-not-so-understood lyrics. These are the words that match that voice and my feelings. And obviously not the exact lyrics.
@PensivePost · Post #4749 · 17.01.2021 г., 05:13
Faith is a big word, Trust is what you can promise. And betrayal is what you fulfill. #review#noob#prose
@PensivePost · Post #5159 · 01.05.2021 г., 16:22
It came from something we can't even see, It took so many lives and gave us the malady, The death, the pain, the anger the disability, Old people say they never witnessed such calamity. With heavy heart, Hope is alive and this is the fact, May the God help us to face all of this, Some people are still doing something wrong, Hope they'll get the fruits of their Unholy act. #anon #noob #review
@PensivePost · Post #5158 · 01.05.2021 г., 16:21
It came from something we can't even see, It took so many lives and gave us the malady, The death, the pain, the anger the disability, Old people say they never witnessed such calamity. With heavy heart, Hope is high, will is strong and this is the fact, May the God help us to face all of this, Some people are still doing something wrong, Hope they'll get the fruits of their Unholy act. #anon #noob #review
@PensivePost · Post #5157 · 01.05.2021 г., 16:20
It came from something we can't even see, It took so many lives and gave us the malady, The death, the pain, the anger the disability, Old people say they never witnessed such calamity. With heave heart, Hope is high, will is strong and this is the fact, May the God help us to face all of this, Some people are still doing something wrong, Hope they'll get the fruits of their Unholy act. #anon #noob #review
@elfcryptovip · Post #12659 · 11.05.2026 г., 10:34
📍 List of abbreviations commonly used in cryptocurrency trading: #ALTCOIN = Alternate cryptocurrency except bitcoin #SHITCOIN = A coin with no potential value or use #BEAR | #BEARISH = Negative price movement #BULL | #BULLISH = Positive price movement #LONG = Margin buy position #SHORT = Margin sell position #BTFD = Buy The Fucking Dip #DILDO = Long green or red candles 😆 #DYOR = Do Your Own Research #FA = Fundamental Analysis #TA = Technical Analysis #FOMO = Fear Of Missing Out #JOMO = Joy Of Missing Out #FUD = Fear Uncertainty & Doubt #HODL = Hold a position #MCAP = Market Capitalization #MOON = Continuous upward movement of price #OTC = Over The Counter #PUMP = Upward price movement #DUMP = To sell off a coin #REKT = When you have a bad loss #WHALE = Very wealthy trader/Market mover #AMA = Ask me anything #ATH = All Time High #ATL = All Time Low #DLT = Distributed ledger technology #IMO = In My Opinion #LAMBO = Lambo is symbol that becomes an elusive goal for most investors #NOOB = A person who is inexperienced #SAFU = Secure Asset Funds for Users #SHILL = Holder of altcoin who just wants to promote it for his own benefit ✅@ElfCryptoVIP