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

Резултати

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

Пребарај: #challenging

当前筛选 #challenging清除筛选
We want you

@we_want_youu · Post #4764 · 17.09.2024 г., 09:35

According to Al-Quran, Surah Ar-Rahman (55:19-23), Allah Almighty presents a powerful and miraculous sign of His creation: He released two seas, meeting side by side. Between them is a barrier, so they do not mix. So which of the favors of your Lord will you deny? In these verses, Allah highlights His supreme authority and wisdom. The reference is to two bodies of water — saltwater and freshwater — that meet but do not mix, remaining separate due to a divine barrier. This natural phenomenon, which scientists have now confirmed, is a profound example of Allah’s control over the natural world. Despite their proximity, the two waters retain their distinct properties, showcasing the perfect balance and system designed by the Creator. #Miracle of the #Quran The Quran was revealed over 1400 years ago, long before modern science understood this phenomenon. The concept of two seas meeting without mixing is something that early humans would have had no scientific means to explain. However, this fact has been witnessed in places like the Mediterranean Sea and the Atlantic Ocean, as well as at river mouths where freshwater meets saltwater. These verses from Surah Ar-Rahman serve as a miraculous scientific truth that confirms the divine knowledge in the Quran, as such occurrences were unknown to humans at the time of revelation. This miracle demonstrates that the Quran is not just a religious text, but also a source of knowledge beyond human capacity. It contains signs that have been confirmed by modern scientific discoveries, proving its authenticity for generations. #Hadeeth and the Understanding of Nature The Quran’s miraculous signs are supported by several teachings in the Hadith (the sayings and actions of the Prophet Muhammad, peace be upon him). The Prophet (PBUH) emphasized reflection on the natural world as a way to understand the power and wisdom of Allah. He encouraged believers to observe the universe as a sign of Allah’s existence, greatness, and mercy. For instance, in one hadith, the Prophet (PBUH) said : "Verily, in the creation of the heavens and the earth, and in the alternation of the night and the day, there are indeed signs for men of understanding. (Sahih Muslim) This emphasizes that everything in the natural world — from the vastness of the cosmos to the interaction of rivers and seas — is a sign of #Allah’s greatness. The separation of the seas is not just a scientific reality, but a reflection of Allah’s control over every element of creation. #Challenging Other #Religions #Islam, through the Quran and Hadith, presents a clear and rational understanding of the world that aligns with both spiritual insight and scientific discovery. Other religions, such as Hinduism, Christianity, and Judaism, do not offer such precise and scientifically verifiable details in their scriptures. While they contain teachings about faith and morality, no other religious scripture provides such detailed descriptions of natural phenomena that can be later confirmed by science, as is the case with the Quran. Why Deny the Truth? The repeated question, "So which of the favors of your Lord will you deny?" is a reminder to humanity that all the signs of Allah’s existence and mercy are evident, yet many people continue to deny or ignore them. These verses challenge the deniers of faith by presenting clear, undeniable evidence of Allah’s creation and control over the universe. In conclusion, this verse from Surah Ar-Rahman, alongside many other Quranic miracles, serves as a testament to the truth of Islam and the divine nature of the Quran. It stands as a proof for both believers and skeptics, showing that no other religion can provide such clear and scientifically proven signs of divine wisdom and knowledge. The separation of the seas is just one of many miracles in the Quran that continue to be confirmed by modern discoveries, making it clear that the Quran is the ultimate source of truth. Thanks for your kindly time