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 слични објави

Пребарај: #electricpower

当前筛选 #electricpower清除筛选
Auto Life

@revheadcrypto · Post #143 · 21.07.2024 г., 13:35

🚀 Introducing the ultimate beast on wheels - Xiaomi's SU7 Ultra! With a whopping 1548 horsepower from its three electric motors, this sedan accelerates from 0 to 100 km/h in just 1.97 seconds and hits 200 km/h in 5.96 seconds. It boasts a top speed exceeding 350 km/h! 🏎️ #Xiaomi#SU7Ultra#SpeedDemon#ElectricPower#NurburgringRecordBreaker🏁🔥

Auto Life

@revheadcrypto · Post #314 · 14.08.2024 г., 11:17

🚗✨ Get Ready for the Modern Audi Sport Quattro! ✨🚗 On August 16th, the highly anticipated modern replica of the iconic Audi Sport Quattro will be unveiled live! 🎉🔥 Announced three years ago, this stunning electric powerhouse from German startup E-Legend boasts an impressive 816 horsepower!⚡💪 With only 30 units planned for production, this exclusive ride is set to turn heads! 😍 #AudiSportQuattro#ELegend#ElectricPower#CarEnthusiast#Supercar#ComingSoon#Auto

Auto Life

@revheadcrypto · Post #661 · 04.12.2024 г., 09:30

🚗💨 Exciting news from Lamborghini! The upcoming Lamborghini Temerario is set to unleash over 1000 horsepower! 🔥 Ruwen Mor, a former Audi engineer now at Lamborghini, revealed that the power of the V8 engine could increase from 200 to around 220 hp per liter. Plus, the car will feature three electric motors for an extra boost! ⚡️ The Temerario follows in the footsteps of the iconic Huracan, which had a naturally aspirated V10 engine with a peak output of 640 hp. While a V6 could have delivered even more power, the decision was made to stick with a higher cylinder count to meet customer expectations. 💪 #Lamborghini#Temerario#Supercar#1000HP#V8#ElectricPower#CarEnthusiast#LuxuryCars#Auto

Auto Life

@revheadcrypto · Post #474 · 11.09.2024 г., 05:53

🚗✨ Introducing the all-new Bentley Flying Spur! ✨🚗 The fourth generation of this iconic sedan has arrived, and it’s not just a pretty face. With a stunning Ultra Performance Hybrid powertrain, it’s now the most powerful four-door Bentley in history! 💪🔋 🔧Power Specs: - 4.0L Twin-Turbo V8 + Electric Motor - 782 hp & 1000 Nm of torque 💥 - 0 to 100 km/h in just 3.5 seconds⏱️ - Up to 76 km on electric power alone! ⚡ #Bentley#FlyingSpur#LuxuryCars#HybridPerformance#CarEnthusiast#Innovation#LuxuryLifestyle#ElectricPower#Auto

Crypto M - Crypto News

@CryptoM · Post #65061 · 10.04.2026 г., 17:36

🚀 France Shifts Focus to Electric Power Amid Rising Oil Prices French Prime Minister Sebastien Lecornu announced a strategic shift in government policy, emphasizing investment in electric power over short-term fuel aid. Bloomberg posted on X that this decision comes in response to the recent surge in oil prices triggered by the conflict in Iran. Lecornu highlighted the importance of supporting households and businesses in transitioning to electric power as a sustainable solution to the energy crisis. The government aims to reduce dependency on fossil fuels and promote cleaner energy alternatives. This move is part of a broader effort to address the economic impact of rising oil prices and ensure long-term energy security for the nation. #France#ElectricPower#OilPrices#EnergyTransition#RenewableEnergy#EnergyPolicy#SustainableEnergy#FossilFuelReduction#EnergySecurity#EconomicImpact

Venture Village Wall 🦄

@venturevillagewall · Post #3725 · 27.12.2024 г., 04:00

Bitwise Launching Bitcoin Standards ETF Bitwise is set to launch the Bitcoin Standard Company ETF, targeting companies with substantial Bitcoin holdings. Criteria include: holding at least 1,000 Bitcoins, market cap over $100 million, daily liquidity of $1 million+, and a public float of at least 10%. Read more In Ethiopia, Bitcoin mining fueled by the Grand Renaissance Dam contributes 18% of the Ethiopian Electric Power Company's revenue. Recent investments in mining have topped $1 billion, with the government partnering with 25 companies to leverage low electricity costs of about 3.2 cents/kWh. Read more #Bitcoin#ETF#Mining#Ethiopia#Electricity#Crypto#Investment#GerD#Revenue#Bitwise#Blockchain#Finance#CorporateReserves#Energy#MarketValue#Liquidity#PublicFloat#Africa#Partnership#InternationalMiners#ElectricPower