Что делать если нужно поставить какую-то 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
BlackRock, Janus Henderson tokenized funds get instant redemptions
A new liquidity network backed by firms including BlackRock (BLK) and Janus Henderson (JHG) is aiming to make the $15 billion tokenized Treasury fund market function better than their traditional counterparts.
Grove, a blockchain-based credit infrastructure specialist, unveiled Thursday a facility designed to provide instant stablecoin liquidity for investors exiting tokenized real-world asset funds.…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
Did Claude just ‘crack’ a bitcoin wallet? AI tool helps find 5 BTC
A viral X post is claiming Claude ‘cracked’ a forgotten bitcoin wallet to recover 5 BTC from a user’s computer.
But don’t get caught in the hype as that is not what happened. Anthropic’s AI simply helped the owner search their own computer for an old wallet file, which was then decrypted with a…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
Joe Lubin’s Consensys has delayed its potential IPO until fall
Consensys, the Ethereum development firm led by Joe Lubin, has pushed back its potential U.S. public offering until fall at the earliest due to poor market conditions, according to two people familiar with the situation.
The MetaMask wallet builder had reportedly engaged bankers from JPMorgan and Goldman Sachs last year to lead the process.…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
Hotter-than-expected inflation data knocks BTC below $80,000
U.S. producer prices for April came in far hotter than expected on Wednesday, complicating the Federal Reserve’s path forward to ease monetary policy later this year.
The April Producer Price Index rose 1.4% month-over-month, nearly triple economists’ expectations for a 0.5% increase. Annual producer inflation accelerated to 6%, while core PPI excluding food and…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
Bitcoin back above $81,000 after hot CPI print, BNB, DOGE lead majors
Bitcoin BTC$80,621.04 shrugged off the inflation scare almost as quickly as the print landed.
The largest cryptocurrency dropped to $79,879 in late U.S. hours Tuesday after the April Consumer Price Index came in at 3.8% year-over-year, hotter than economists had estimated, with gasoline prices doing most of the lift since the Iran war began.…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
JPMorgan (JPM) to launch new tokenized fund as Wall Street
JPMorgan (JPM) is preparing to launch a tokenized money market fund, the latest sign that major financial institutions and Wall Street asset managers are speeding up efforts to move traditional assets onto blockchain rails.
A Tuesday filing with the U.S. Securities and Exchange Commission SEC) outlined plans for a blockchain-based money-market fund investing exclusively…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
CleanSpark stock slides 9% as quarterly earnings miss estimates on
CleanSpark (CLSK) stock fell over 9.4% in pre-market trading on Tuesday after the U.S. bitcoin BTC$80,644.99 mining company reported a widening net loss of $378.3 million for its second fiscal quarter, hit by a significant non-cash adjustment to its digital asset holdings.
The company reported a net loss of $378.3 million for the quarter…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
What next for XRP as related firm Ripple grabs $200 million funding
XRP keeps pushing into the same resistance area that has rejected rallies since February, but the way it’s trading is starting to change. Price is no longer getting sold off immediately after touching the range. Instead, XRP is holding near the highs, which usually matters more than the initial breakout itself.
News Background
•…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
Strategy’s Michael Saylor says selling bitcoin to fund dividends is
When Strategy (MSTR), the largest publicly traded company holding bitcoin, first floated the idea of selling its bitcoin stash to fund its dividend obligations during its recent earnings call, it raised concerns among investors and the crypto community.
However, executive chairman Michael Saylor sat down with CoinDesk senior analyst James Van Straten at Consensus…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
Bitmine buys 26K ether (ETH) after Tom Lee said to slow down
Bitmine Immersion Technologies (BMNR) has sharply slowed its ether (ETH) purchase pace as Chairman Tom Lee signaled, following months of aggressive buying that made it the world’s largest Ethereum treasury company.
The firm bought 26,659 ether last week, worth about $63 million based on ether’s current price. That’s roughly a quarter of the average…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
Ripple-linked XRP spikes 2.5%, beating bitcoin and ether, in breakout
XRP finally forced its way through the $1.45 area that had capped rallies for weeks, and the move came fast. Volume arrived all at once during the breakout, which usually points to larger positioning rather than retail chasing, though the rally started losing momentum as price approached the psychological $1.50 level.
News Background
•…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─
Policy at Consensus Miami: State of Crypto
White House adviser Patrick Witt said it’s possible the Clarity Act becomes law by July 4 while Senator Kirsten Gillibrand pushed for an ethics provision in the market structure bill. Consensus Miami 2026 wrapped up with a fiery debate on the role of prediction markets, and a lot otherwise happened at our first conference…
#BlockchainTechnology#CryptoNews
─┅━━━━━⊰✵⊱━━━━━┅─
│📣 : @bovinebear │
│🤖 : @bovinebear_bot│
─┅━━━━━⊰✵⊱━━━━━┅─