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

Резултати

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

Пребарај: #milestone

当前筛选 #milestone清除筛选
Viral Today

@Viral_Today · Post #1758 · 23.01.2022 г., 13:00

🎉Thank you for 10.000 followers! Thank you all for commenting, reacting and sharing our posts. It is always great to hear back from you! You can always suggest a post or contact us through our bot @ChannelYTNBot Stay tuned for more content! YouTubeNews/ #milestone

Hashtags

Venezuelanalysis

@venanalysis · Post #1461 · 28.01.2024 г., 14:43

A blend of US aggression and Venezuelan opposition collusion has all but sealed CITGO's destiny. Discover how Washington and its local allies successfully acquired Venezuela's US-based refiner, valued at US $10-13 billion, by clicking here 👉🏽https://bit.ly/3OkSfn8. View and download the infographic in a single image. Don't miss out on these insights! #CITGO#Infographic#milestone

SingSing Announcement

@singsingchannel · Post #680 · 08.07.2024 г., 04:06

🚀 We did it! Our community keeps growing stronger with over 90K Followers on X and more than 1 million on-chain transactions! 🚀💫 🎉 The numbers are still climbing, and we couldn't be more grateful for your support. Together, we'll keep reaching new heights! 💪🔥 Read more and open treasure at: X Post #Milestone#CommunityPower#Blockchain#Crypto

SingSing Announcement

@singsingchannel · Post #692 · 11.07.2024 г., 08:59

🎉 Milestone Alert! 🎉 SingSing has officially surpassed 1.2 MILLION on-chain transactions! 🚀 Thank you to our incredible community for making this possible. Here’s to many more milestones ahead! 💪✨ Read more and open treasure at: X Post #SingSing#Blockchain#Milestone#OnChain#CryptoCommunity

SingSing Announcement

@singsingchannel · Post #752 · 06.08.2024 г., 08:19

New Milestone🚀🚀 We've just hit the milestone of 500,000 Web3 users utilizing SingSing SocialFi SDK! 🎉🚀 Thank you for your support and participation. This achievement showcases the strength and potential of the SingSing community! 💪✨ Keep exploring and enjoying the super cool features of SingSing! 💎🔥 #SingSing#Web3#SocialFi#Milestone#SDK

Venezuelanalysis

@venanalysis · Post #1751 · 20.09.2024 г., 23:39

When discussing historic speeches, one stands out: President Hugo Chávez at the UN General Assembly on September 20, 2006. He labeled U.S. President George W. Bush a war criminal and highlighted Western hypocrisy regarding democracy and peace—right from “the devil’s house.” Chávez criticized the UN for its alignment with U.S. interests and called for reform led by the Global South. He underscored the ongoing struggle for change and the potential for a better future. Click here to learn more and watch the key quotes 👉🏼https://shorturl.at/guOJh #Milestone#HugoChávez#UN#Revolution

TMONK Announcements

@tmonkannouncements · Post #28 · 25.03.2024 г., 22:54

💎TMONK as you know, was born to spread the word of Telegram and its founder Durov. We said that we want to become the first #crowdfunding and #charity platform and we are working on both fronts. And so we are really proud to present the first AMBASSADOR on the #TONBlockchain regarding the charity sector. A person of absolute morality and great devotion to the cause. That who has already given part of his life to helping people in the field and who knows the ton chain deeply 👀👀👀Jeribond.ton🆒🆒🆒 Our Ambassador brings with a wealth of experiences and knowledge that make him an outstanding choice to represent TMONK. We are honored to have his leadership and inspiration to guide others on our journey. This is the first step to build the foundation of a structure that can be the #milestone in this theme for ton chain 🤝 About Jeribond.ton🤝 After working in the humanitarian sector for 8 years, Jeribond.ton has just resigned and is focusing on Web3. Jeribond.ton worked in the neonatal and maternal health sector for this while, because over here women face a lot of pregnancy complications and also newborn babies pre or post. So JERI worked in the community by training the health workers, doctors, and nurses to best carry out their duties using best practices that work in other countries, and this helped to reduce the rate of how women die. Jeribond.ton was instrumental as he managed the supplies and supported the work in many ways; with a small team obtained funding from an international organization to carry out these projects. BioCM - $TON$BNX - BD lead & Advisor @Tonraffles - @Roolznft $Fish OG @binaryniglions@https://t.me/tonnigeria @https://t.me/TonNomadsChat This is a crucial step for the advancements of our project, and we are truly proud to announce this new and exciting collaboration. We aim to build something new, something incredible that can help all the people in need around the world. FOR THEIR #FREEDOM

SingSing Announcement

@singsingchannel · Post #894 · 13.10.2024 г., 16:43

🎉100,000 Players and Counting!🎉 A huge THANK YOU to our incredible community for making SingSing Tycoon such a massive hit! 💥 Your support has helped us reach this amazing milestone, and we couldn’t have done it without you. 🙌 Here’s to many more tycoon adventures ahead! 🏗️💰 #SingSingTycoon#100KPlayers#Milestone#ThankYou#GameFi 🎤Announcement | Chat | X (Twitter) | Website | Game

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