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

Резултати

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

Пребарај: #freehk

当前筛选 #freehk清除筛选
Hong Kong Democracy Movement

@hkdmovement · Post #8055 · 09.08.2025 г., 05:58

Hong Kong’s Universities Under Tight Control The CCP has long turned mainland universities into tools of ideological control—and now it’s doing the same in Hong Kong. Under a new accountability agreement, eight public universities must align with Xi Jinping’s remarks and national goals. Critical thinking? That’s the last thing the CCP wants. Education is becoming indoctrination. 香港大學教育正被政治操控 中共早已將中國高校變成洗腦機器,現在同樣的模式正在香港上演。根據新問責協議,八所公立大學必須與習近平講話及國家目標保持一致。 批判性思維?這正是中共最不希望人民擁有的能力。教育正在淪為思想灌輸。 https://hongkongfp.com/2025/07/30/hong-kong-public-universities-sign-new-accountability-agreement-requiring-alignment-with-xis-remarks #academicfreedom#CCP#FreeHK

Hong Kong Democracy Movement

@hkdmovement · Post #8095 · 23.09.2025 г., 04:25

Chan Yin-lam’s Death | 陳彥霖之死 Chan Yin-lam, a 15-year-old student, died under mysterious circumstances during the 2019 Hong Kong protests. Her case sparked widespread speculation and public concern. Timeline: Sept 19, 19: Last seen barefoot leaving Youth College, heading toward Tseung Kwan O waterfront Sept 21: Reported missing by family Sept 22: Naked body found floating near Yau Tong Oct 9: Police confirmed identity as Chan Yin-lam Oct 10: Body cremated Sept 20: Jury returned an open verdict—neither suicide nor homicide confirmed Controversies: Autopsy estimated body had been in water for 15–60 hours, implying at least 16 hours unaccounted for before entering the water No signs of assault, but full nudity raised questions Allegations of protest involvement; police denied arresting her Some acquaintances claimed the woman shown on TV was not her real mother, and said they could no longer contact her #ChanYinLam#FreeHK#HKProtest

Hong Kong Democracy Movement

@hkdmovement · Post #8048 · 31.07.2025 г., 02:13

Big Brother is growing bigger: 4,000 new surveillance camera sets coming to Hong Kong by 2027. Hong Kong police plan to install 2,000 sets this year and another 2,000 next year to fight crime. But this expansion also raises serious concerns about freedom and privacy. With facial recognition and AI integration, critics warn this could further tighten the CCP’s grip on the city. What can the CCP do with this surveillance power? - Track individuals in real time - Identify and monitor political dissidents - Link footage with national security databases - Suppress protests and public gatherings - Enforce censorship and digital control - Extend surveillance to online behavior and diaspora communities 香港將於2027年前增設4,000組監控鏡頭,進一步限制自由! 警方計劃於2025年和2026年分別安裝2,000組鏡頭,表面上是為了打擊罪案,但實際上可能加強中共對香港的控制。人臉識別與人工智能系統的加入,引發對隱私與自由的憂慮。 中共可透過監控做什麼? - 即時追蹤個人行蹤 - 鎖定並監視異見人士 - 與國安資料庫連結 - 打壓示威與集會活動 - 實施言論審查與網絡控制 - 擴展至海外港人社群的監控 #BigBrotherIsWatchingYou#HKPoliceState#FreeHK

Hong Kong Democracy Movement

@hkdmovement · Post #7013 · 15.01.2024 г., 16:35

"Hong Kong's independent bookstores face government scrutiny, closures, and accusations of stifling opinions and erasing local culture. 'Mountain View Bookstore' shut down due to mounting challenges in addressing complaints. 'Prejudice Book Room' in Kwun Tong ordered to vacate, citing alleged violations. Critics argue these actions are part of a broader campaign to suppress dissenting voices and erode Hong Kong's unique cultural identity. Concerns grow over the diminishing space for diverse opinions and cultural expression. #HongKongBookstores#CulturalErosion #FreeHK

Hong Kong Democracy Movement

@hkdmovement · Post #8094 · 23.09.2025 г., 04:17

陳彥霖,15歲學生,在2019年香港反修例運動期間離奇死亡,引發社會廣泛關注與質疑。 時間線: 2019年9月19日:最後一次被目擊,赤腳離開青年學院,前往將軍澳海邊 9月21日:家人報警失蹤 9月22日 :在油塘附近海面發現全裸女屍 10月9日:警方確認屍體為陳彥霖 10月10日 :遺體火化 2020年9月:死因庭裁定「開放式裁決」,無法確定自殺或他殺 關鍵細節與爭議: 法醫報告指出屍體在水中時間為 15至60小時,意味著她失蹤後至少 16小時才進入水中 無明顯外傷,但全裸狀態引起疑慮 傳言與示威活動有關,警方否認曾拘捕她 有認識其母親的人表示,電視上的女子並非其母親,且 無法再聯絡真正的母親 #ChanYinLam#HKProtest#FreeHK#CCP

Hong Kong Democracy Movement

@hkdmovement · Post #7314 · 05.04.2024 г., 04:47

Due to China's increasing influence and the implementation of a new national security law, Hong Kong's economic position has been severely shaken. The erosion of the city's autonomy and the tightening grip of Chinese authorities have raised concerns among international businesses, leading to a decline in investments and a loss of confidence in Hong Kong as a global financial center. This, coupled with the redirection of cargo and the restructuring of shipping routes, has further diminished Hong Kong's economic prospects. https://www.rfa.org/cantonese/news/hk-link-04042024161154.html #ChinaInfiltration#NSL#freeHK#standwithhongkong

Hong Kong Democracy Movement

@hkdmovement · Post #7841 · 23.09.2024 г., 03:13

5 years ago today, Chan Yin Lam passed away mysteriously. During 2019, many HongKongers went missing or died. Several times #HKPolice were caught throwing bags with the size of a human into the sea. Her body was found in the sea, naked, yet people knew her claimed that she was a diver. #HKProtest#neverforgiveneverforget #FreeHK

Hong Kong Democracy Movement

@hkdmovement · Post #6958 · 04.01.2024 г., 12:07

Jan 3: on day 5 of #JimmyLai's trial, prosecutors claiming he directed #AppleDaily's English edition to promote "yellow" viewpoints and seek foreign sanctions. They mention Lai's Twitter account, where he followed figures like Tsai Ing-wen and Mike Pence. The judge questioned the relevance, but prosecutors argue it shows Lai's connections and state of mind. Critics see these charges as an attack on free expression. Jimmy Lai's trial highlights the concerning reality that having a Twitter account can now be used against individuals in prosecutions. The case underscores the potential risks individuals face for expressing their viewpoints and connecting with others on social media platforms. #FreedomOfExpression#freehk#freepoliticalprisoners

Hong Kong Democracy Movement

@hkdmovement · Post #8068 · 22.08.2025 г., 18:23

The #HK government denied a #Bloomberg reporter from entering Hong Kong. Bloomberg is considered as the most reliable source for investors around the world. I guess #CCP is doing her best to sabotage Hong Kong as financial hub and run full on communist. #PressFreedom#freedomofspeech#freeHK

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