Что делать если нужно поставить какую-то 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
#sponsered
🚨Position - Web3 Community Manager
📍Location - 100% Remote
👀Language - English
💰Salary - $95k/year, crypto payments + bonuses
NatureLand
A sustainable metaverse
We are currently seeking several community managers to join our project team.
Responsibilities
📍Engage in communication and moderation within our Discord chat, providing assistance to Discord members.
📍Monitor and maintain a clean chat environment, ensuring adherence to community guidelines.
📍Respond to support tickets and provide timely assistance to users.
📍Manage interactions on our primary Twitter account, addressing inquiries and engaging with the community.
📍Handle email correspondence on our corporate email account.
In this role, you will be actively involved in interacting across Twitter, Discord, and Email platforms.
Apply - https://forms.gle/rBgUHVzJFb4dgLQa7
🔴 Disclaimer: We aren't not affiliated with the NatureLand in terms of hiring and emphasizes that we are merely sharing the opportunity as part of our collaboration.
#sponsered
🚨Position - Web3 Community Manager
📍Location - 100% Remote
👀Language - English
💰Salary - $95k/year, crypto payments + bonuses
NatureLand
A sustainable metaverse
We are currently seeking several community managers to join our project team.
Responsibilities
📍Engage in communication and moderation within our Discord chat, providing assistance to Discord members.
📍Monitor and maintain a clean chat environment, ensuring adherence to community guidelines.
📍Respond to support tickets and provide timely assistance to users.
📍Manage interactions on our primary Twitter account, addressing inquiries and engaging with the community.
📍Handle email correspondence on our corporate email account.
In this role, you will be actively involved in interacting across Twitter, Discord, and Email platforms.
Apply - https://forms.gle/rBgUHVzJFb4dgLQa7
🔴 Disclaimer: We aren't not affiliated with the NatureLand in terms of hiring and emphasizes that we are merely sharing the opportunity as part of our collaboration.
#sponsered
🚨Position - Web3 Community Manager
📍Location - 100% Remote
👀Language - English
💰Salary - $95k/year, crypto payments + bonuses
NatureLand
A sustainable metaverse
We are currently seeking several community managers to join our project team.
Responsibilities
📍Engage in communication and moderation within our Discord chat, providing assistance to Discord members.
📍Monitor and maintain a clean chat environment, ensuring adherence to community guidelines.
📍Respond to support tickets and provide timely assistance to users.
📍Manage interactions on our primary Twitter account, addressing inquiries and engaging with the community.
📍Handle email correspondence on our corporate email account.
In this role, you will be actively involved in interacting across Twitter, Discord, and Email platforms.
Apply - https://forms.gle/rBgUHVzJFb4dgLQa7
🔴 Disclaimer: We aren't not affiliated with the NatureLand in terms of hiring and emphasizes that we are merely sharing the opportunity as part of our collaboration.
👀📊🐳🏦BankP2PGold has launched on PancakeSwap. More marketing on the line . Don't miss out !
🐰https://pancakeswap.finance/swap?outputCurrency=0xD3ab8287C03A6cF8655264c6749cDb5fCCEe0260
🪪KYC ✅AUDIT ✅SAFU 🏦
A P2P Wallet and Exchange for cryptocurrencies, offering security and convenience in a single platform.📱App for Android, iOS and Windows 📊P2P Decentralized Exchange 🎖KYC, Safu and 2 audits ✅ALREADY listed on CMC and CG 💲 Fees: 10% [8 % Marketing + 2% Passive Token Revenue] 🐳 Global pre and post launch marketing campaign! (+30 channels and influencers)
🌐Website:https://p2pgold.io
🕊Twitter:https://twitter.com/bankp2pgold
✈️Telegram:https://t.me/bankp2pgold
#Dyor#Sponsered
#Sponsered#Ads#DYOR
😍😍😍😍😍😍😍😍😍😍😍😍😍
✅ HOLD 1 TRILLION SHINT COIN ✅
AND GET A NFT WORTH 1 BNB
😍😍😍😍😍😍😍😍😍😍😍😍😍
SHIBA INTERSTELLAR is the first Crypto project created to finance space exploration,
research of new materials and technologies.
SHINT will finance high-tech StartUps oriented to space travel.
The current price of Shiba Interstellar is cheap
The great opportunity is to buy now and wait for the project to burn 5 zeros.
Go to +50.000 %
Total supply: 1.000.000.000.000.000
Symbol: SHINT
Contract Address: 0xca2f9ce9967c1717f5a2539d525a9a8bca3dea3b
You can buy on PANCAKESWAP or DEX-TRADE
https://pancakeswap.finance/swap?outputCurrency=0xca2f9ce9967c1717f5a2539d525a9a8bca3dea3b
Social links:
✅ website: WWW.INTERSTELLAR-TOKEN.com
✅ Telegram: t.me/shibainterstellar1
✅ Twitter: @interstellar_xt
🏦
🐂🕊@BANKp2pGOLD
✅
✅
🪪We want to warn our community to prepare for our first listing on 🏦CMC
Ⓜ️ and 🏦CG
🦎
🏦PANCAKESWAP:
🥇
🐰https://pancakeswap.finance/swap?outputCurrency=0xD3ab8287C03A6cF8655264c6749cDb5fCCEe0260
🔶
💸
Ⓜ️
🦎
🏦Telegram: t.me/bankp2pgold
✈️
🏦Website: p2pgold.io
🪪
🥇Don't miss out. It's the next 🏦1000X🏦 $GEMs CEX Coin
🐂🚀
💸TAX: 10/10 Marketing & Listing Development: 8% Passive Income Holders: 2%
🐂
🐂
🐂The Leading Cryptocurrency Exchange About Us Bank P2P Gold is an international centralized exchange based in New York, launched in 2023. As the number one cryptocurrency exchange in terms of token variety, it positions itself as a trusted platform for cryptocurrency projects. cryptocurrencies. cryptocurrencies with the aim of attracting initial investors.
🐂
🐂
#Sponsered#NFA#DYOR
Hello Everyone 👋
Do you still trade in Web 2.0? i.e investment platforms. You're going the wrong way!!!
Do you know MevBots are here??
Use MevBot to interact with the Ethereum blockchain system using your wallets directly by yourself, Install and activate MevBot directly through Etherscan
Use MevBot Smart Contract
• Sandwich
• Liquidate
• Front Run pending Tx
• Carry out arbitrageon dex.
🚫 No third party systems/platforms 🚫
Need To Know:
How to Interact With Etherscan using Metamask or Trustwallet
Install MEV (Miner Extractable Value) programming codes
Activate Bot
Free trials available!!
Join:https://t.me/+j2EohR37FfgyNWI0
Research: web 3.0, MEV
Work with professionals!
#DYOR#NFA#Sponsered
#Advertisement
📈 SaveInvest - Unleash Profits, Embrace Power! 🚀✨
- Opportunity to boost investment portfolio
- Mark calendars and prepare
- Short window, plan to maximize benefits
▶️Register Now:Click here
🚀 Starting on 10 May 2024, an exciting opportunity awaits all investors!
🚀 From 10 May to 30 May 2024, you'll receive a 10% bonus on your investment.
🚀 Plus, you'll receive a 10% bonus for referrals! 🎉
💬Note - Please do your own research (DYOR) before joining any project, Invest only that part of your portfolio which you can bear to lose #NFA#Sponsered#DYOR
#Advertisement
🚀Discover an exciting investment opportunity with @IVEX_token - it's too good to miss!
Explore IVEX for diverse investment options that are garnering attention across platforms!
💥 The buzz around their ICO is growing! Act quickly as investor interest rises, and limited free points are available!
💼 Backed by prestigious European funds, IVEX offers a credible investment platform!
But wait, there's more…
📈 IVEX's expected investment amount has already tripled! Join us on this journey towards success!
🎉$10,000 GIVEAWAY ALERT 🎉
Don't forget to participate in our ongoing giveaway for a chance to win big!
🌎Check out our social media channels for details:
✈️Telegram:https://t.me/ivex_token
✈️ Telegram Group: https://t.me/IVEX_OfficialChat
📷Instagram:https://www.instagram.com/ivex_token/
✖️Twitter:https://twitter.com/ivex_token
💬Note - Please do your own research (DYOR) before joining any project, Invest only that part of your portfolio which you can bear #NFA#Sponsered#DYOR
🚀A Financial Step Forward! Your Future Begins with FutureX!
🤝 We understand that trust is the foundation of every successful investment decision. That’s why we created FutureX, a platform where every step is transparent and every transaction is secure. Join thousands of people who have already taken this important step and entrusted us with managing their capital.
💡 We’re not just offering you an opportunity to invest, we’re offering you a partnership. We’re with you every step of the way, providing experts, education, and tools to ensure your financial steps are confident and successful.
⬆️FTF TokenAirdrop from Futurex:GIFT2024
📌First Steps:
✅ Fund your account with $100 and receive a $20 bonus on your trading account. After account activation, you’ll get early access to the FTF coin AirDrop.
✅ Participate in ETH staking from 1 to 30 days with instant withdrawal upon completion and zero FutureX fees.
✅ AI Trading - earn 10% to 30% per month with zero FutureX fees.
✅ Flexible referral system with passive income.
🔥CryptoCredit line for our clients who have completed KYC, offered by our partners at a 15% rate.
🥇With FutureX, your financial step turns into success as soon as tomorrow!
®Note - Please do your own research (DYOR) before joining any project, Invest only that part of your portfolio which you can bear #FutureX#Sponsered#DYOR
💎 A revolution in the tap2earn industry
70% price growth of the monorix project in just one day🔥
Listed on bingx exchange !✅
Less than 2 weeks left until token deposit and listing in the next exchange...🎯
More valuable than hamsters and... !!!🚀🚀
😀 FOLLOW MonorixOFFICIAL CHANNELS FOR THE LATEST UPDATES:
✉️ Telegram:
https://t.me/monorixofficial
✉️Telegram Bot:
https://t.me/monorixbot?start=174107049
🕊 Twitter (x): https://x.com/themonorix?t=4DpA5sV6Uh5eL1UPdZf5_g&s=09
📷 Instagram: https://www.instagram.com/monorixcom?igsh=MXRteG1reGRnN3RxOQ
🌐 Website:
https://monorix.com
®Note - Please do your own research (DYOR) before joining any project, Invest only that part of your portfolio which you can bear #monorix#Sponsered#DYOR
#Advertisement
🚀Discover an exciting investment opportunity with @IVEX_token - it's too good to miss!
Explore IVEX for diverse investment options that are garnering attention across platforms!
🔴The buzz around their ICO is growing! Act quickly as investor interest rises, and limited free points are available!
💼 Backed by prestigious European funds, IVEX offers a credible investment platform!
But wait, there's more…
📈 IVEX's expected investment amount has already tripled! Join us on this journey towards success!
🎉$10,000 GIVEAWAY ALERT 🎉
Don't forget to participate in our ongoing giveaway for a chance to win big!
🌎Check out our social media channels for details:
✈️Telegram:https://t.me/ivex_token
✈️Telegram Group:https://t.me/IVEX_OfficialChat
📷Instagram:https://www.instagram.com/ivex_token/
✖️Twitter:https://twitter.com/ivex_token
®Note - Please do your own research (DYOR) before joining any project, Invest only that part of your portfolio which you can bear #NFA#Sponsered#DYOR