Что делать если нужно поставить какую-то 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
In Japan, a marketing campaign called 'kokoro no kaze' (a cold of the soul) was used to promote antidepressants, increasing sales sixfold. It falsely suggested depression was simple and temporary like a cold, hiding the true treatment needs. This led to over-medication and potential harm. Now, companies focus on bipolar disorder, risking similar issues. 🚨💊
[Read more]
@googlefactss
#MentalHealth#Japan#Pharmaceuticals#Depression#Bipolar#HealthRisks
🚀 Hong Kong's Innovative Drug Sector Gains Momentum
Hong Kong's innovative drug sector is experiencing a surge, with several companies showing significant gains. According to Jin10, Ascletis Pharma (01672.HK) saw an increase of over 3%, while Hansoh Pharmaceutical (03692.HK) rose by more than 2%. Other companies such as WuXi AppTec (02359.HK) and Sihuan Pharmaceutical (00460.HK) also followed suit with upward trends.
#HongKong#Pharmaceuticals#Biotech#Innovation#StockMarket#Healthcare#DrugDevelopment
$2.16M Fundraising by Umecrine
Umecrine Cognition, a Swedish clinical-stage pharmaceutical firm, has raised $2.16 million to advance its innovative drug development targeting neurological disorders. The funding round took place on December 19, 2024.
#UmecrineCognition#Pharmaceuticals#NeurologicalDisorders#Funding#Healthcare#ClinicalStage#Sweden
Massive Funding Rounds Highlight Emerging Tech
🔍 Recent funding rounds spotlight key players in various industries:
- Zenith Energy: $1.18B for remote off-grid and urban microgrid power solutions. More Info
- Kommunalkredit Austria: $209.71M investment to enhance societal quality of life. More Info
- Hanyang Technology: Secured $200M, focusing on technology development. More Info
- Duetti: $200M to revolutionize music catalog acquisitions from independent artists. More Info
- Peregrine Technologies: $190M aimed at improving public safety management. More Info
- TK Elevator: $166.05M raised to enhance elevator technology. More Info
- Zhipu AI: $137.27M funding for AI development, including high-precision knowledge maps. More Info
- Geneus: $100M dedicated to science and technology advancements. More Info
- Swap: $40M for enhancing ecommerce shipping and tracking. More Info
- Atmosic: $40M for innovative battery-less technology solutions. More Info
- Ocean Yield: $35M for investments in maritime assets. More Info
- Viam: $30M towards AI and automation engineering solutions. More Info
- Coalition: $30M for cybersecurity insurance and services. More Info
- Danking Pharmaceuticals: $20.59M focused on innovative pharmaceutical research. More Info
- IdentifySensors: $20M for biomarker detection technology. More Info
- LlamaIndex: $19M for developing AI knowledge assistants. More Info
- Heidi Health: $16.60M for AI-driven healthcare documentation. More Info
- Prime Intellect: $15M for accessible AI development platforms. More Info
#AI#VC#Energy#Tech#Pharmaceuticals#Ecommerce#Cybersecurity#Music#PublicSafety#Automation#HealthTech
🚀 Germany's Industrial Output Falls Unexpectedly in February
Germany's Federal Statistical Office announced on Thursday that industrial output in February unexpectedly declined, with energy price shocks from Middle Eastern conflicts expected to further suppress production. According to Jin10, industrial output fell by 0.3% month-on-month in February, following a revised flat reading in January. The market had generally anticipated a 0.5% increase for February. The decline in output was primarily driven by decreases in the construction sector, as well as in the electronics, optical products, and pharmaceutical industries. In contrast, the Federal Statistical Office noted that automobile production saw growth after a significant drop in January.
#Germany#IndustrialOutput#Economy#Manufacturing#Construction#Electronics#Pharmaceuticals#Automobile#EnergyPrices#February
$140M Funding for Ottimo Pharma
Ottimo Pharma announces a funding round of $140 million set for December 19, 2024. The company focuses on developing bi-functional medicines aimed at improving the lives of individuals living with cancer.
Learn more
#Funding#OttimoPharma#Cancer#BiFunctionalMedicines#Healthcare#Pharmaceuticals#LifeSciences#Investments#MedicalResearch#Oncology#HealthTech#Biotechnology
PeproMene Bio Secures $11M Round
PeproMene Bio, Inc., a clinical-stage biotech firm based in Irvine, CA, has successfully raised $11 million in funding. The investment round closed on December 18, 2024, focusing on innovative therapies targeting cancers and immune disorders.
More info: PeproMene Bio
#Biotech#Funding#Cancer#ImmuneDisorders#California#ClinicalStage#Therapies#Investment#Healthcare#Innovation#PeproMeneBio#Pharmaceuticals#MedicalResearch#DrugDevelopment
Turn Therapeutics Secures $75M Funding
Turn Therapeutics, specializing in advanced wound and dermatologic care, has raised $75 million in funding. The investment aims to boost their innovative pharmaceutical and medical device offerings using proprietary technology. For more details, visit their website: Turn Therapeutics.
#Funding#Biotech#Healthcare#Pharmaceuticals#MedicalDevices#WoundCare#Dermatology#Investment#Innovation#Technology#TurnTherapeutics#Proprietary#AdvancedCare#Medical#Company#Therapeutics#Research#Development#Startups
$4.07M Funding for PeptiSystems
PeptiSystems secured $4.07M in funding on December 20, 2024. The company develops advanced instruments for solid-phase synthesis in peptide and oligonucleotide therapeutics, catering to both GMP and non-GMP manufacturing. Discover more: PeptiSystems
#Funding#PeptiSystems#Therapeutics#Peptides#Oligonucleotides#GMP#Manufacturing#Synthesis#Biotechnology#Pharmaceuticals#MedicalDevices#FlowthroughColumnTechnology#ProcessDevelopment#LifeSciences