kohya_ss
kohya_ss copied to clipboard
Make portable update some error!
fisrt install protable location d:\AiTools\kohya_ss can be updated and run normally
When my usb device was moved to another computer it got a different drive letter, for example: location from d:\AiTools\kohya_ss to s:\AiTools\kohya_ss
run : git pull and run fix_setup.bat choose option 1 ,get error :
"Fatal error in launcher: Unable to create process using '"D:\AiTools\kohya_ss\ext\python\python.exe" "S:\AiTools\kohya_ss\ext\python\Scripts\pip.exe" install -r requirements_windows.txt -U': ???????????"
The protable bat file I made: fix_setup.bat :
@echo off
: set env
set "PATH=%PATH%;%CD%\ext\git\cmd"
set "PATH=%PATH%;%CD%\ext\python"
:set python_environment_variables
set PYTHON=%CD%\ext\python\python.exe
set PYTHON_SCRIPTS=%CD%\ext\python\Scripts
set PIP_NO_WARN_SCRIPT_LOCATION=0
:set huggingface
set HF_ENDPOINT=https://hf-mirror.com
set HF_HOME=%CD%\ext\.huggingface
set HF_HUB_DISABLE_SYMLINKS_WARNING=1
:set xformers
set XFORMERS_FORCE_DISABLE_TRION=1
:set cu_environment_variables
set CU_PATH=%CD%\ext\python\Lib\site-packages\torch\lib
:set_environment_variables
set "PATH=%PATH%;%CU_PATH%;%PYTHON_SCRIPTS%"
echo Updating...
git reset --hard
git pull
: call .\setup\setup_windows.py
IF /i "%comspec% /c %~0 " equ "%cmdcmdline:"=%" (
cmd /k %PYTHON% .\setup\setup_windows.py
) ELSE (
%PYTHON% .\setup\setup_windows.py %*
)
:end bat
pause
Python scripts using subprocess.run(run_cmd, shell=True, check=False, env=os.environ) will still use the old Python location, This problem can be fixed normally after I modify the code
file: setup_common.py old code:
if upgrade:
optional_parm += " -U"
if show_stdout:
run_cmd(f'pip install -r {requirements_file} {optional_parm}')
else:
run_cmd(f'pip install -r {requirements_file} {optional_parm} --quiet')
log.info(f'Requirements from {requirements_file} installed.')
new code is ok:
if upgrade:
optional_parm += " -U"
if show_stdout:
run_cmd(f'python -m pip install -r {requirements_file} {optional_parm}')
else:
run_cmd(f'python -m pip install -r {requirements_file} {optional_parm} --quiet')
log.info(f'Requirements from {requirements_file} installed.')
use python -m pip to install dependencies using the Protable Python environment implanted in bat. I'm not very good at Python code. I don't know where Python's subprocess.run command caches the old python.exe path. Can you solve this problem? I really need a protable-available installation package.
The python code is made to run in a venv and I don't know the extent of changes to make thios possible... I will look at it when I have the time but I don't want to introduce too many changes...
What is the error message you are getting? THe python code set the PYTHONPATH internally as:
env["PYTHONPATH"] = (
fr"{scriptdir}{os.pathsep}{scriptdir}/sd-scripts{os.pathsep}{env.get('PYTHONPATH', '')}"
)
Perhaps I would check for the presence of an already set env variable and skip that when found? Like... if you could set KOHYA_GUI_PORTABLE=1 I could then not set that use the PYTHONPATH environment variable you would set would be used? Like with:
if os.getenv("KOHYA_GUI_PORTABLE") == "1":
pass
else:
env["PYTHONPATH"] = (
fr"{scriptdir}{os.pathsep}{scriptdir}/sd-scripts{os.pathsep}{env.get('PYTHONPATH', '')}"
)
Try changing this in one of the GUI script like dreambooth_gui.py and let me know if it help. If it does I could easilly implement it in the code without much impact.
I have created a new branch called portable-gui
to implement the changes... You can use it for testing... I moved the environment code into common_gui.py so you can easilly modify the code to test what might make things work:
我创建了一个名为
portable-gui
实现更改的新分支...您可以使用它进行测试...我将环境代码移至 common_gui.py 中,以便您可以轻松修改代码来测试可能使事情正常工作的内容:
ok,i will try it .