<分区>
如何在 python 脚本中使用 pip 安装软件包? 我不使用 os.system,我想导入 pip 并使用它。
<分区>
如何在 python 脚本中使用 pip 安装软件包? 我不使用 os.system,我想导入 pip 并使用它。
最佳答案
pip.main() 不再适用于 pip 版本 10 及更高版本。您需要使用:
from pip._internal import main as pipmain
pipmain(['install', 'package-name'])
为了向后兼容,您可以使用:
try:
from pip import main as pipmain
except ImportError:
from pip._internal import main as pipmain
关于python - 在 python 脚本中使用 "pip install/uninstall",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12937533/
相关文章:
python - 名称错误 : name 'argv' is not defined
python - 在 Python 中实现 MSNP15 - 911 错误,但所有票证都是正确的
python - setuptools和pip的依赖解析的区别
python - pip 安装 : upgrade a library in/usr without sudo
python - mysql-connector-python、mysql-connector-python-rf 和 mysql-connector-repackaged 有什么区别?
python - (Python) 属性错误 : 'NoneType' object has no attribute 'text'
python - 使用for循环python在mysql表中插入值
python - 从 pypi 安装 Pip 有效,但从 testpypi 失败(找不到要求)