TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #210 · 3 фев.

Что делать если нужно поставить какую-то 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

Резултати

Пронајдени 17 слични објави

Пребарај: #reflection

当前筛选 #reflection清除筛选
Doniyor Olimjonov English | IELTS

@doniyorieltss · Post #1472 · 20.05.2023 г., 01:55

#reflectionon my recent results... For a start, let me just say that I'm more than grateful for another 8.5, not least because it's an improvement over the last one. Yes, I've come so close to securing that elusive Band 9. You know what? I even thought I did. But for me, it's not so much about the score as it is about fun and experience. As much as I may come across as someone chasing after a 9.0, I honestly couldn't care less. Clearly, it is a big milestone and for good reason — very few people understand what it takes to really get there, and I'm fortune enough to be one of them. But I already stopped caring too much about what I now know is nothing but a number — at least I'm trying to do so. In fact, I did not even prepare for this test of mine, which I normally would. I just wanted to see if I was good enough to score a 9.0 on Speaking and 8.0 on Writing; apparently, I am not! In any case, it was all supposed to be fun — something that I did just for the sake of a dopamine hit; a 180-dollar one, in fact. 😅 Seriously, even as I was taking the Speaking test, I could barely suppress the joy that I felt creeping up, because that was the best performance I'd ever put on in my life! There is also a sense of elation at waiting for your results, even more so when you don't know the exact day of the release. And having fun with your friends until 3.00 AM on the occasion of a satisfactory result is a whole nother level! To sum it all up, I would love to achieve what appears to be the greatest feat of IELTS — Band 9.0. However, I shouldn't have to work for it, as it is not priority 'numero uno': the score is supposed to be only a fraction of a lifelong endeavour — at least for me it is! @ieltsulugbeks

Hashtags

Doniyor Olimjonov English | IELTS

@doniyorieltss · Post #1279 · 31.03.2023 г., 18:44

#reflection Lurching from one task to another, I have been finding myself get sucked into the whirlwind of work time and again. That dreadful thing! It's so counterproductive: You want to lead an exemplary lifestyle, and so you work. You think all your troubles will fade away as you take up work. Little do you know, however, more ordeals than ever before are looming on the horizon — starting a new career, unless tapped into, is a surefire way to put a bigger strain on your already deteriorating social life. Instead of lightening your burden, your work just keeps making you all the more miserable, and before you know it, you will be enslaved by what was only supposed to help you. @ieltsulugbeks

Hashtags

Financial Freedom Magazine

@FinancialFreedomMagazine · Post #1067 · 13.12.2021 г., 04:39

THIS WEEK... Instead of a weekly #book challenge, we have a #reflection challenge. Basically, the idea is to use this time of year to intentionally discover and align yourself with the work you’re meant to do in 2022. To help you with this, you can download ⬇️ --The 2021-22 Annual Reflection Template-- It's a structured deep dive into who you are, who you might become, and what you want to create for 2022.

Quiet World 🍁

@QuietWorld · Post #6688 · 11.10.2019 г., 08:30

Men go abroad to wonder at the heights of mountains, at the huge waves of the sea, at the long courses of the rivers, at the vast compass of the ocean, at the circular motions of the stars; and they pass by themselves.., without wondering. – St. Augustine – #solitude#quotes#reflection @quietworld🍃

12
ПретходнаСтраница 1 од 2Следна