mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-02-04 09:17:41 +08:00
30 lines
717 B
Python
30 lines
717 B
Python
import time
|
|
import pip
|
|
from pip._internal import main as pipmain
|
|
from common.log import logger,_reset_logger
|
|
|
|
def install(package):
|
|
pipmain(['install', package])
|
|
|
|
def install_requirements(file):
|
|
pipmain(['install', '-r', file, "--upgrade"])
|
|
_reset_logger(logger)
|
|
|
|
def check_dulwich():
|
|
needwait = False
|
|
for i in range(2):
|
|
if needwait:
|
|
time.sleep(3)
|
|
needwait = False
|
|
try:
|
|
import dulwich
|
|
return
|
|
except ImportError:
|
|
try:
|
|
install('dulwich')
|
|
except:
|
|
needwait = True
|
|
try:
|
|
import dulwich
|
|
except ImportError:
|
|
raise ImportError("Unable to import dulwich") |