Что делать если нужно поставить какую-то 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/1902187576448127204
ALL Time High:
Nifty 50
26277-3240=
22.5x144
45x72=23037
23037-72-72-72(3x72) =216, 6 cube
1440/45=32
158.5x144=
79.25x288=22,824
22824+144+72
320x72 =23,040
#Gann: use 45 however possible!
If one cycle misses it goes to next only!
https://x.com/priceactiongann/status/1813056880333262989
#nifty from 21300 to 24676 almost all upside is done!
"THE END" of buy calculations after that lost motion or next movement will decide!
price level is almost close and time is also up,
when reaches encoded time is up , but as per time cycle course concept its date is in 2 days july 18 th so this week up to Monday will be high alert !
#stocks#GANN#stockmarket#nifty50
https://x.com/priceactiongann/status/1805511429052572126
#banknifty
top price cycle mentioned!
will decide here and nifty price 23910 and this price 53463 will complete in same time!
#stocks#stockmarket#gann#stocks#nifty50
https://x.com/priceactiongann/status/1850744650472071270
#NIFTY#niftycrash
Most important Historic Update:
Nifty 50, 23949 and 23767 will be Historic,
24335 holds barrier on top!
432% Must hold levels and Deciding Given!
Future Market will should and Must hold and Decide 23949 and 23767 only!
Can have bounce and then it will Decide!
If broken and retest will be here and This changes Everything.
if not holding this would take the price to 22222 only!
#stocks#stockmarket#gann
https://x.com/priceactiongann/status/1850744650472071270
Do Follow and Support More on x!
https://x.com/priceactiongann/status/1959557093356425295?t=iZQ12tlqHhQz3g5N-WiKIQ&s=19
#nifty#nifty50
Develop your senses- especially learn how to see. Realize that everything connects to everything else. I have been impressed with the urgency of doing. Knowing is not enough; we must apply.
leonardo da vinci
Nifty 50 Cycles of Fractals shown
cycles of 90 ,84,360,168,21,7,144 all in play with in the markets in Nifty
Image analysis watched with this post is of more important and contain many ideas if you work on it
fib cycles are also in direct cause and effect with price and time
many such fractals and direct cycles we must find.
Time cycle dates
September 23
October 30
for longer term
"one idea can change your entire life"
Every thing is circles ,squares and Triangles only
#Timecycle#gann#stockmarketsindia
https://x.com/priceactiongann/status/1807966606338769095
#nifty#nifty50
Time cycle date 18 th july !
perfect date with top numbers aligning !
must see a low or high on that day or volatility !
#stocks#stockmarket#stockmarketsindia#gann#Trading
when we know the rules we know the time well in advance!
https://x.com/priceactiongann/status/1805508785793851642
#nifty final price on top price cycle !
completing its short term numbers and time cycle yesterday bottomed clearly and broke all time high today!
almost all done when bigger cycle completes better to avoid when reached 23535 but for update iam posting this worst case is on top 23910 to 24000 !
timecycle date also gave high and low it needs to be broken down for furthermore downside!
until it stays on top of the zone and 23535 it will be up only!
#stocks#stockmarkets#stockmarketindia#nifty50#gann
https://x.com/priceactiongann/status/1810679429456089540
#GOLD#XAUUSD
EXACT HIGH OF THE DAY to the pip accurate top!
from down it went up and once reaches price Encoded it just dropped 144 pips and more!
#pricecycle and #timecycle meets.
cannot give any more perfect result than this!
#priceaction#trading#stockmarket#gann
https://x.com/priceactiongann/status/1806296904663228873
#nifty
23910 done in nifty #timecycle helped from 24 th,
price will decide here now, OLHC etc.
weekly price close will be very interesting!
, when #banknifty reaches 54583 u will see some magic! wait and see!
#stocks#stockmarket#stockmarketindia#gann#OptionsTrading
https://x.com/priceactiongann/status/1810493611676467665
#trading#gold
Gold time cycles explained,
forecasted price history,
Encoded deciding price, direction
#xauusd shorter time frame time,
stop hunt and over all in big time frames its in ranging
explained in images do watch and share more!
#priceaction#gann#pricecycle#timecycle
#Silver#commodity
https://x.com/priceactiongann/status/1810493611676467665
https://x.com/priceactiongann/status/1808716644535185767
Same cycles ! With exact numbers !
#banknifty 54583
#nifty 24676
#GIFTNIFTY 24780
When any of these reaches first stay high alert!
I do not see any more massive buy even if It goes it's slight extention and it all ends here in big scale!
When price touches it might take days or weeks or can react instantly too!
Almost all upside done as per me and my studies when price reaches these levels!
The more if it extends upside even after Reaching this price ,sooner or later is should , will and must come back to 23535!
#stocks#stockmarkets#trading#stockmarketindia#StockMarketNews
#gann#nifty50