Что делать если нужно поставить какую-то 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
https://x.com/priceactiongann/status/1830485509040206276
#NIFTY
✅25300 is top price and all top side done as per my studies and cycle ends as stated several time long term 25192 and short term 25300!
✅give long term downside time from here!
don't gamble intraday and lose more in weekly options
✅without a doubt it will go down more at least 500 points sooner or later from here and more to come!
✅ give maximum time and benefit it!
https://x.com/priceactiongann/status/1830485509040206276
https://x.com/priceactiongann/status/1805149402027200627
#nifty
indian markets retest on top and can drop or deicide,
let it complete and time cycle date today 24th!
so mark yesterdays (fridays low and high price) and use it for upcoming days direction, patterns that forms there
weekly close and monthly
close will be very crucial!
Show more
https://x.com/i/status/2037865158207475768
#nifty
Hard truth:
"Many don't like sell trend at all especially in Indian market "
All few know is ,market will simply go upside nomatter the price or time
They couldn't even tolerate when the market drops,
When no knowledge this is what happens.
Just buy buy buy ...gamble in weekly options .
Many newcomers after corona or recent newcomers who enter trading don't even know what cycles or about time and price
Only a very few understand the reality and indepth concepts
They always listen,study and improvise
Especially adapt as per cycles and research.
Know when to enter and when to shut up and be silent
If not market will make u suffer without mercy.
#stockmarket
https://x.com/priceactiongann/status/1858784604171231577#nifty50#nifty
23747 will be Major Price Encoded!
watch out here!
23535 bounce Confirms cycle vibrations and proves our theory too!
#StockMarket
https://x.com/i/status/2037845679603929594
#nifty
Nifty clarification:
Cycle 1 is supposed to go 27000 to 28800 which is valid as long as 23300 to 23900 above price stays
Cycle 2: from top 27000 to 28800 it was supposed to drop massive
Since 2024 the same happened nifty was leading and later dropped
But in this case calculations vary once 23300 is broken everything changes
After this crisis later it will be up and again down so we know 3 to 5 cycles if one dint reach the expected level
Check all my previous posts if a level is missed especially if it's jackpot ot other it goes back
So this phase mostly can drop u yil the 23900 holds simple as that.
Once this drop is done later from it goes to 28800 or more which is way way advanced and ahead iam posting this may be after 2 to 4 years all will See without a doubt.
Check as per market moves and use your own and combine and keep it simple
I dont recommend or advice. It's merely my studies i post .
#nifty50
https://x.com/priceactiongann/status/2032731952021910011?s=20
#nifty
Nifty 50 will go up massive upside 5500 points and more in upcoming weeks
23300 to 28800 in the very long term.
One of the biggest bull trends is about to start
Bookmark this post
All the three defences 24507 , 23900, 23600 and last one where I used jackpot 1 year ago is reached now only at 23300
Look closely all the levels had a bounce first or low there and again breaches down
The only level or calculation was missed and it took it's time and it's finally it's also done now
#nifty50
Finally 23300 is most important and above it is upside and below it is downside.
Most likely upcoming weeks will be up more
23300 will be historic for sure.
23300 above once the price goes there will be more up only.
Everything is maths and geometry only.
https://x.com/priceactiongann/status/1876209418213237011
#niftycrash#nifty
We Just hit Double Jackpot!
576 points at least from 24150!
with price 23990 were warned clearly!
First day few will troll
Next day these few will listen and be calm
The third day u will be my fan or follower!
so don't waste Your energy just hit my follow button and learn already!
keep calm and show results "consistently"
focus on your work and trust in ur skills always!
https://x.com/priceactiongann/status/1812717128442650654
#giftnifty
All time high in gift nifty is 24676 exact !
Also last week high of nifty 50,
#nifty still pending !
Both these are inter related so vibrations can be obvious !
learn to see!
https://x.com/priceactiongann/status/2029152658855207421?s=20
#nifty Nifty 50 price is exactly at 24355 and 24507 which was my older level
zone is in between 23900 and 24355 where many cycles coincide there
both will be very strong barrier and will hold the price upside and strong cycles starts there.
there we watch for clear confirmation.
Time cycle date is around March 5
March and April will see historic movements
just wait and see.
even if it reaches 23300 there is huge upside cycle still in play the more it drops the more it will be up only.
#StockMarketIndia
https://x.com/priceactiongann/status/1988641789180551183?s=20
#banknifty
Get set and Ready!
Bank nifty strongest Encoded price cycle
58507 bookmark this post!
Upcoming cycles all will be related to this level only.
massive movements are yet to come below this will be down and above this will be massive such deciding factor here.
one of the largest movements are yet to come starts from tomorrow!
weekend will be clear and next week it will be more obvious!
#Nifty#StockMarket
https://x.com/priceactiongann/status/1861784516916035816
🚨"The Pause Before the Panic"🚨
Might not get a better chance to exit portfolio!
#Sensex also pointing at 72000 from current price 80470 !
#nifty🛑Pray that 23300 holds 🛑,
If breached, expect a non-stop decline.
#nifty50
https://x.com/priceactiongann/status/1861784516916035816