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

Резултати

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

Пребарај: #amabit

当前筛选 #amabit清除筛选

📣The Nexus Wallet and Drop Hunter team announced the launch of a new project – Amabit! 📊 This is a trading broker terminal (all in one), which has strong partners: Binance, Bybit and OKX, 300+ cryptocurrencies are currently available for trading. Tools of the new crypto platform #Amabit: 🟨 Trading on top exchanges 🟨 Ability to connect to trading bots 🟨 Wealth and portfolio management 🟨 Investing in #DeFi 🔥Drop Hunter is slowly transforming into #superapp, which will have the functionality of an exchange, a wallet and a gamified platform for #airdrop. ❤️ In addition, Nexus Wallet also had a big update, adding: 🟨 DEX exchanges 🟨 NFT support 🟨 Simplified withdrawal of funds 🟨 P2P market 🟨 QR NFT and wallet security improvements 🩹 Now there are some technical problems with the game Drop Hunter, but next week the team plans to restart the farming function and fix all the bugs, so we are waiting. Game | Chat | Channel | YouTube | Nexus

☕️Drop Hunter is launching another airdrop, but this time with #Amabit 📊 Amabit is an all-in-one brokerage trading terminal from the Drop Hunter team, which has strong partners: #Binance, #Bybit and #OKX, 300+ cryptocurrencies are currently available for trading, more details here. 💰 A total of 2,000,000 $DROP coins will be distributed between all participants, compared to the airdrop from #Bybit, twice as many tokens, the rewards for each participant have been increased by 4 times, while the number of winners has been reduced by 2 times. The requirements for participation are below: 🟡Launch the bot. 🟡Register on Amabit and complete KYC. 🟡Join the Amabit chat and send a screenshot showing that KYC is completed. 🟡Invite 5 friends (old referrals count). 🟡Buy 1 ticket and wait for the results to be announced. 📇 Additional information for participants – you get 20% of the winning ticket of your friend you invited. This means that if you invited 10 people and they won at least 1 ticket, you will receive 40 #DROP tokens from each ticket. 🟡Drop type – Raffle. 🟡Total volume – 2,000,000 $DROP. 🟡Total winners – 10,000 people. 🟡For each user 200 $DROP for 1 ticket (20,000 points = 1 ticket). 🔥 We remind you that the #DropHunter team is planning a token listing on a major exchange in the fall, so we continue to farm and participate in all their airdrops. Game | Chat | Channel | YouTube | Nexus

💰Drop Hunter launched the first airdrop in $DROP token! 🎟 In #airdrops tab, it is now possible to exchange farmed coins for tickets, which increase the chances of receiving their $DROP token. The conditions are as usual simple: 🟨Log into the bot and go to the "airdrops" tab 🟨 Invite 3 friends and subscribe to the desired channels 🟨 Exchange collected coins for tickets 🟨 Wait for the end and check the internal wallet 🚀 Let us remind you that, according to the team, $DROP is a utility token of the ecosystem, which includes the projects: #Amabit, #DropHunter and #NexusWallet. It will be used to pay for internal services. 💎Rewards: 500K out of 8M total supply. 🟡 Drop type – raffle 🟡 Total winners – 3300 people 🟡 $DROP for each winner 🔥 Closer to autumn, the team is planning to list the #DROP token on a major exchange, so let's continue to farm and participate in all their airdrops. Game | Chat | Channel | YouTube | Nexus