Answer the question
In order to leave comments, you need to log in
How to install libraries via code without cmd?
This question has probably been asked before, but I'll ask anyway. How to install libraries without using cmd? In cmd, installation is done like this pip install name, but how to do it in the code itself?
Answer the question
In order to leave comments, you need to log in
pip - sort of like a python module - accordingly, you can programmatically run commands using module procedures:
from pip._internal.cli.main import main
main(['install', 'xlrd'])
#Collecting xlrd
# Downloading xlrd-2.0.1-py2.py3-none-any.whl (96 kB)
# |████████████████████████████████| 96 kB 541 kB/s
# Installing collected packages: xlrd
# Successfully installed xlrd-2.0.1
# WARNING: You are using pip version 21.1.1; however, version 21.2.4 is available.
# You should consider upgrading via the '/opt/.../rvenv/bin/python -m pip install --upgrade pip' command.
import xlrd
xlrd.__version__
# '2.0.1'
main(['freeze'])
# aioredis==1.3.1
# amqp==5.0.6
# argon2-cffi==20.1.0
# asgiref==3.3.4
# ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question