Что делать если нужно поставить какую-то 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
Good Morning Traders...
Be ready for our weekly report coming soon 👌
FxSignals_Gold analyst brutally butchered the market this week with unbeatable killing result and performance 😱 Our daily and consistent performance speaks for itself... We take maximum pride in what we do💃🕺
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
Dear Traders,
Welcome each and everyone to a new trading week, we commence this week in the name of God 🙇♂️ a fruitful, buoyant and pips_gain week to everyone.
Huge pips ahead this coming week. Lots of scanned trade setups. FxSignals_Gold analyst would be crushing the market.
Lots of accounts would be doubled stay tuned mates, let's help you grow.
Let’s make this the best week of your trading career so far... Let's catch you some serious 💵💴
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FrxMaster_Gold
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Good Morning Traders...
Be ready for our weekly report coming soon 👌
FxSignals_Gold analyst brutally butchered the market this week with unbeatable killing result and performance 😱 Our daily and consistent performance speaks for itself... We take maximum pride in what we do💃🕺
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
Dear Traders,
Welcome each and everyone to a new trading week, we commence this week in the name of God 🙇♂️ a fruitful, buoyant and pips_gain week to everyone.
Huge pips ahead this coming week. Lots of scanned trade setups. FxSignals_Gold analyst would be crushing the market.
Lots of accounts would be doubled stay tuned mates, let's help you grow.
Let’s make this the best week of your trading career so far... Let's catch you some serious 💵💴
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FrxMaster_Gold
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Happy Tuesday My Champions! 😎
Success in trading starts with the right mindset and honing our skills. Let's focus on improving our knowledge and decision-making abilities. Embrace the hustle and pray for wisdom.
Thank you, God and the Universe, for guiding us. Here's to a profitable and wise trading day ahead! 🙏
☎️Forex Master
#AccountManagement
#PropFirmChallenge&Verification✅
Good Morning Traders...
Be ready for our weekly report coming soon 👌
FxSignals_Gold analyst brutally butchered the market this week with unbeatable killing result and performance 😱 Our daily and consistent performance speaks for itself... We take maximum pride in what we do💃🕺
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
Happy Friday My Champions! 😎
Every great dream begins with a dreamer ✨
Always remember, you have within you the strength, patience, and the passion to reach for the stars to change the world! 👌
Believe in yourself & have faith in your abilities. Don't let nobody steal your dream! 🔥
Wish it, plan it, do it!
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
FxSignals_Gold Weekly Report - ( From 28/10/24 To 01/11/24)
90% Success rate, +916Pips delivered this week🔥🔥
Quick Pips Summary⤵️
⚡️Net Profit: +916Pips
🔎Total Signals: 16
⏳Running Signals: 1
⚠️Losing Pips: -100 Pips
🎯Winning Pips: +1,016Pips
🏆Total Net Profit Gained: +916Pips
We build loyalty, Real loyalty. We extract every pip we can from the markets, precision!
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FrxMaster_Gold
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Dear Traders,
Welcome each and everyone to a new trading week, we commence this week in the name of God 🙇♂️ a fruitful, buoyant and pips_gain week to everyone.
Huge pips ahead this coming week. Lots of scanned trade setups. FxSignals_Gold analyst would be crushing the market.
Lots of accounts would be doubled stay tuned mates, let's help you grow.
Let’s make this the best week of your trading career so far... Let's catch you some serious 💵💴
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FxGoldHubClientSupport
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
FxSignals_Gold Weekly Report - ( From 21/10/24 To 25/10/24)
80% Success rate, +603Pips delivered this week🔥🔥
Quick Pips Summary⤵️
⚡️Net Profit: +603Pips
🔎Total Signals: 13
⏳Running Signals: 0
⚠️Losing Pips: -150 Pips
🎯Winning Pips: +753Pips
🏆Total Net Profit Gained: +603Pips
We build loyalty, Real loyalty. We extract every pip we can from the markets, precision!
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Good Morning Traders...
Be ready for our weekly report coming soon 👌
FxSignals_Gold analyst brutally butchered the market this week with unbeatable killing result and performance 😱 Our daily and consistent performance speaks for itself... We take maximum pride in what we do💃🕺
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
FxSignals_Gold Premium VIP Daily Performance 🔔
Wednesday - 05/02/2025
Swing Trade » 🟠Buy GBPAUD (-50Pips)
Swing Trade » 🟠Sell XAUUSD (+37Pips)
Scalp Trade » 🟠Sell XAUUSD (+30Pips)
Swing Trade » 🟠Buy GBPJPY (+32Pips)
Scalp Trade » 🟠Sell XAUUSD (+86Pips)
Scalp Trade » 🟠Sell XAUUSD (+39Pips)
Swing Trade » 🟠Buy XAUUSD (-50Pips)
Scalp Trade » 🟠Sell XAUUSD (+80Pips)
⚡️Net Profit: +208Pips
🔎Total Signals: 8
⏳Running Signals: 1
⚠️Losing Pips: 100 Pips
🎯Winning Pips: +308Pips
🏆Total Net Profit Gained: +208Pips
Always remember, never lose sight of your goals. Start Investing in your dreams. No matter how hard it gets, not matter what challenges you face, look forward and never ever give up!
Join the list of others who have found their success in forex with FxSignals_Gold VIP with very low and affordable subscription fee.
Starting from $49 per Month
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FrxMaster_Gold
#PropFirmChallenge&Verification✅
#FUNDEDAccountManagement👨🏻💻