Skip to content

'cp' is not recognized as an internal or external command (on Windows) #644

@JAY-IZEX-LLC

Description

@JAY-IZEX-LLC

Description:
When attempting to create a custom LoRA model using FaceChain on a Windows system, the process fails with the following error (train_style/demo.py):

'cp' is not recognized as an internal or external command, operable program or batch file.

This happens because FaceChain internally invokes a Python command like:

os.system('cp {} {}'.format(file_path, new_path))

However, the cp command is Unix/Linux specific and is not available in the Windows command prompt.

Expected Behavior:
The FaceChain process should copy files correctly and complete the creation of the custom LoRA model on any supported platform, including Windows.

Suggested Fix:
Update the code to use a cross-platform solution like Python’s shutil.copy instead of the cp shell command:

shutil.copy(file_path, new_path)
Index: train_style/demo.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/train_style/demo.py b/train_style/demo.py
--- a/train_style/demo.py	(revision 7bc7119c54deab7de6b29f0d14bd6f51d7d98a1c)
+++ b/train_style/demo.py	(date 1753092233061)
@@ -40,7 +40,7 @@
         # 放到临时目录
         if os.path.exists(new_path):
             os.remove(new_path)
-        os.system('cp {} {}'.format(file_path, new_path))
+        shutil.copy(file_path, new_path)
         # 居中裁剪图片到512*512
         cut_img(new_path)
         new_imgs.append([new_path, prompt])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions