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

Резултати

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

Пребарај: #june2023

当前筛选 #june2023清除筛选
The Open Platform

@topco · Post #67 · 04.07.2023 г., 08:59

DeFi: June headlines - Real-world asset protocols outperform DeFi blue chips due to tokenization wave. The top uncollateralized lending protocols for institutions, TrueFi and Maple, have increased by 26.6% and 117.8%, respectively, in 2023. Centrifuge, a real-world asset tokenization platform, has surged by 32% year to date (source). - DeFi Platform EigenLayer Rolls Out Restaking Protocol on Ethereum Mainnet, EigenLayer's developers raised $64.5 million in a series of investment rounds (source). - Arbitrum-Based DeFi Project Chibi Finance Rug Pulled: Over $1 Million Drained: On-chain analysis conducted by blockchain security platform CertiK revealed that Chibi devs deployed a malicious contract that enabled them to steal user funds from the protocol’s smart contracts (source). - DeFi Protocol Maverick Raises $9M Led by Peter Thiel's Founders Fund, the round also included contributions from Pantera Capital, Binance Labs, Coinbase Ventures and Apollo Crypto (source). - BlackRock Executive: Knowing Who Counterparties Are Is Key to Engaging Institutions in DeFi. Issues such as the automated market making in DeFi instead of central order limits books are just fig leaves, said Chalom. "We need clear understanding of who is in a pool" (source). #DeFi#trends#June2023

The Open Platform

@topco · Post #70 · 07.07.2023 г., 09:02

Metaverse: June headlines - Consumers appear less interested in more futuristic offerings, want real-world applicability, are least interested in fashion and beauty, loosing interest in metaverse socializing - McKinsey & Company (source) - Apple bets on the metaverse: Apple unveiled its long-awaited entry into virtual reality, or what the tech giant calls “spatial computing,” in the form of the Apple Vision Pro, a $3,500 device that looks like exquisitely designed futuristic ski goggles (source). - Banks Have Come to the Metaverse. JPMorgan arrived in Decentraland under the brand Onyx, which, according to the company, is “a blockchain-based platform for wholesale payment transactions.” DBS, Singapore’s biggest bank, purchased a large plot of land on The Sandbox to develop interactive experiences aimed at promoting a more sustainable world. South Korea’s Kookmin Bank has its own native metaverse-based financial services as well as one-on-one customer service (source). #metaverse#trends#June2023

The Open Platform

@topco · Post #69 · 06.07.2023 г., 09:02

Web3 Creator Economy: June headlines - Mythical Games Secures First Close of $37 Million Towards Latest Round of Funding. The round was led by digital asset manager Scytale Digital, with participation from ARK Invest, Animoca Brands, PROOF, Stanford Athletics, MoonPay. Existing investors, including Andreessen Horowitz, Gaingels, Signum Growth, Struck Capital, and WestCap also participated in the round. Mythical is a next-generation games technology company creating a web3 gaming ecosystem by leveraging blockchain technology and playable NFTs for tools that enable players, creators, artists, brands and game developers to become stakeholders and owners in new “play and own” game economies (source). - NFT Creation Platform Zora Launches Creator-Focused Layer 2. In a statement to CoinDesk, a spokesperson for Zora said that the platform has been building a "culture of creativity and community" since its inception, putting artists and creators at the forefront of its products (source). #creatoreconomy#trends#June2023

The Open Platform

@topco · Post #68 · 05.07.2023 г., 09:01

Wallets / Payment Solutions: June headlines - PayPal invests in new crypto wallet service. PayPal has announced a substantial investment in Magic, the strategic funding round, led by PayPal Ventures, raised $52 million for Magic, with additional investments from Cherubic, Synchrony, KX, Northzone and Volt Capital (source). - Atomic Wallet Hackers Use THORChain to Conceal Stolen $35M Funds: the hackers, believed to be North Korean hacking group Lazarus, have been using cross-chain bridges and liquidity protocols to mix stolen funds (source). - Crypto​.com joins ranks of licensed payment institutions in Singapore: with the MPI license, Crypto.com is now authorized to offer its DPT services to customers in Singapore (source). - Crypto Payments Firm Wyre Winding Down Due to ‘Market Conditions’. Wyre is ceasing operations less than a year after it was valued at $1.5 billion in an abortive acquisition by Bolt (source). - Binance struggles in Europe continue as it has lost its EURO payment partner - Paysafe,its Euro payment partner, will stop its bank transfers services from September 25 (source). - Mastercard plans beta for a blockchain ‘app store’ for ‘regulated’ financial apps. Mastercard said it was planning to launch a beta in the U.K. over the summer to test what it calls the Multi Token Network, or an “app store powered by blockchain technologies for building regulated financial applications” (source) #wallet#paymentsolutions#trends#June2023