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

Резултати

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

Пребарај: #djangocon

当前筛选 #djangocon清除筛选
djangoproject

@djangoproject · Post #591 · 29.03.2018 г., 06:56

https://2018.djangocon.us/ Six days of talks, sprints, and tutorials in San Diego October 14-19 2018 #DjangoCon US has something for everyone, from the person who develops Django applications for a living to the person who just tinkers in their spare time. You'll discover details about a range of diverse applications that people from all over the world are building with Django, get a deeper understanding of concepts you’re already familiar with and discover new ways to use them, and have a lot of fun!

Hashtags

djangoproject

@djangoproject · Post #590 · 29.03.2018 г., 06:46

https://2018.djangocon.eu/ #DjangoCon Europe 2018 in Heidelberg May 23-27, 2018 · Heidelberg, Germany We are trying very hard to make this conference enjoyable to you even before it has started. One of the things we hope will be helpful is this timeline. Please understand that this is a rough timeline – as we cannot see into the future, some things might move around, but we will communicate every noticable change in a blog post!

Hashtags

djangoproject

@djangoproject · Post #371 · 04.07.2017 г., 14:47

https://2017.djangocon.us/news/tutorial-announcement/ #djangocon 🔹From 0 to 100 in Django 🔹How to React the Right Way (Django + React) 🔹Catching Tweets with Django + Django REST Framework 🔹Build a GraphQL API Using Django 🔹Build and Launch a Website on Wagtail, in Three Hours! 🔹Don’t Touch That Dial! An Introduction to Channels

Hashtags

djangoproject

@djangoproject · Post #370 · 04.07.2017 г., 14:18

https://2017.djangocon.us/ #djangocon Six days of talks, sprints, and tutorials by the community for the community. August 13–18 2017 🔸Flourishing FLOSS: Making Your Project Successful (Anna Ossowski) 🔸Functional Programming in an Imperative World. Maybe (Derik Pell) 🔸Understanding JavaScript Libraries via React and the React Ecosystem (Andrew Pinkham) 🔸Becoming a Polyglot: Lessons from Natural Language Learning (Rebekah E. Post) 🔸The Shy Person’s Guide to Tech Conferences (Ed Rivas) 🔸The CoC Committee Is Here for You (Erik Romijn) 🔸hunter2: A Symphony of Password Horror (Lilly Ryan) 🔸Files in Django (Josh Schneier) 🔸Programming Post-Progeny: A New Parent’s Perspective (Jacinda Shelly) 🔸Don’t Use My Grid System (Or Any Others) (Miriam Suzanne) 🔸Butter Smooth, Interactive Applications with Django and Websockets (Ganesh Swami) 🔸The 10 Commandments of Community Organizing (Jennifer Wadella) 🔸Exhausted Octopus Learns a Thing!! (Laura R. Webb) 🔸The Denormalized Query Engine Design Pattern (Simon Willison) 🔸Tasks: You Gotta Know How to Run ‘Em, You Gotta Know How to Safe ’Em (Filipe Ximenes)

Hashtags

djangoproject

@djangoproject · Post #369 · 04.07.2017 г., 14:08

https://2017.djangocon.us/ #djangocon Six days of talks, sprints, and tutorials by the community for the community. August 13–18 2017 🔸Saved You a Click (Or Three): Supercharging the Django Admin with Actions and Views (Liam Andrew) 🔸Django vs Flask (David “DB” Baumgold) 🔸End-to-End Django on Kubernetes (Josh Berkus) 🔸Going Rogue: How Code.org Created a Curriculum Development Platform without their Engineers (Josh Caldwell) 🔸Overcoming the Challenges of Mentoring (Kim Crayton) 🔸Stumbling Through Django and How Not to (Melanie Crutchfield) 🔸Maybe Not the Programmers They Deserved, but the Programmers They Needed (Jessica Deaton and Megan Will) 🔸GraphQL in the Wild (Arianne Dee) 🔸Accessibility Matters: Creating a Better Web (Lindsey Dragun) 🔸Taking Django Distributed (Andrew Godwin) 🔸The Monster on the Project (Tiberius Hefflin) 🔸Python & Spreadsheets: 2017 Edition (Kojo Idrissa) 🔸Type UWSGI; Press Enter; What Happens? (Philip James) 🔸Serverless Django (Rich Jones) 🔸Live long and refactor :vulcan_salute: (Sana Javed) 🔸Preventing Headaches with Linters and Automated Checks (Flávio Junior) 🔸Autopsy of a Slow Train Wreck: the Life and Death of a Django Startup (Russell Keith-Magee) 🔸The Beauty of ViewSets in Django Rest Framework (Buddy Lindsey, Jr.) 🔸Getting the most out of Django’s User Model (Julia M Looney) 🔸Alexa… (Heather Luna aka Heats) 🔸Write an API for Almost Anything (Or The Amazing Power and Flexibility of Django Rest Framework) (Charlotte Mays) 🔸The Power :zap: and Responsibility :sweat: of Unicode Adoption :sparkles: (Katie McLaughlin) 🔸Practical Unit Testing in Django (Wayne Merry) 🔸Using Django, Docker, and Scikit-Learn to Bootstrap Your Machine Learning Project (Lorena Mesa) 🔸Get a Jumpstart on Collaboration and Code Review in GitHub (Katherine “Kati” Michel) 🔸Why Can’t Everyone Just Do What I Want Them To? Leadership, Management, and Working with People Who Don’t Think like You (Briana Morgan)

Hashtags

djangoproject

@djangoproject · Post #368 · 04.07.2017 г., 13:39

http://2017.djangocon.com.au/ #DjangoCon AU: August 4, 2017 #PyCon AU: August 5 - 6, 2017 Sprints: August 7 - 8, 2017 🔷Django and JavaScript: A long and complicated friendship 🔷Bowerbirds of Technology: Architecture and Operations at Less-Than-Facebook Scale 🔷Loop better: a deeper look at iteration in Python 🔷Oh, I Found a Security Issue 🔷Offline Django with Service Workers 🔷hunter2: A Symphony of Password Horror 🔷Multitenant applications: how and why 🔷Horrors of Distributed Systems 🔷Red User, Blue User, MyUser, auth.User