代码拉取完成,页面将自动刷新
# 这个文件是用来快速初始化的
import argparse
import subprocess
import sys
# use python type hints to make code more readable
from typing import List, Optional
def pip_install(proxy: Optional[str], args: List[str]) -> None:
if proxy is None:
subprocess.run(
[sys.executable, "-m", "pip", "install", "-i", f"https://pypi.tuna.tsinghua.edu.cn/simple", *args],
check=True,
)
else:
subprocess.run(
[sys.executable, "-m", "pip", "install", f"--proxy={proxy}",*args],
check=True,
)
def main():
parser = argparse.ArgumentParser(description="install requirements")
parser.add_argument(
"--proxy",
default=None,
type=str,
help="specify http proxy, [http://127.0.0.1:1080]",
)
args = parser.parse_args()
# 如果后期有需要添加的包就写这个列表里
pkgs = f"""
numpy
opencv-python
opencv-contrib-python
imutils
pillow
pyserial
"""
for line in pkgs.split("\n"):
# handle multiple space in an empty line
line = line.strip()
if len(line) > 0:
# use pip's internal APIs in this way is deprecated. This will fail in a future version of pip.
# The most reliable approach, and the one that is fully supported, is to run pip in a subprocess.
# ref: https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program
# pip.main(['install', *line.split()])
pip_install(args.proxy, line.split())
print("\nsuccessfully installed requirements!")
if __name__ == "__main__":
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。