Faceswap.py启动失败求助:模块缺失与路径导入错误问题
Let’s work through these issues one by one, focusing first on the most blocking and unusual final error:
1. Fixing Missing Dependencies (tqdm, pynvml)
Manually installing individual packages is error-prone—Faceswap maintains a curated set of dependencies that should be installed in bulk to avoid version mismatches. Instead of installing tqdm and pynvml one-off, navigate to your Faceswap directory in PowerShell and run:
pip install -r requirements.txt
If you’re sticking to CPU mode (since you hit the NVML library warning), use the CPU-specific requirements file if it exists (check the Faceswap repo for requirements-cpu.txt):
pip install -r requirements-cpu.txt
This ensures you get all correct versions of every dependency, not just the ones you noticed were missing.
2. Resolving the "NVML Shared Library Not Found" Warning
This warning appears when pynvml can’t locate NVIDIA’s driver libraries (common if you don’t have an NVIDIA GPU or haven’t installed the full CUDA toolkit). Switching to CPU mode was the right call here—just make sure you launch Faceswap with the --cpu flag if required, or set the mode in your config file.
3. Fixing ModuleNotFoundError: No module named 'Users'
This odd error almost always stems from Windows path parsing issues. Here’s what to check:
- Avoid spaces in installation paths: If your Faceswap folder or Python virtual environment lives in a path like
C:\Users\Your Name\Faceswap, the space in your username might cause a script to misinterpret part of the path as a module name. Try moving Faceswap to a space-free path (e.g.,C:\Faceswap). - Verify virtual environment activation: If using a virtual environment, ensure you’ve activated it correctly in PowerShell before launching Faceswap:
Using the global Python install can lead to path conflicts that trigger this error..\your-venv-folder\Scripts\Activate.ps1 - Inspect config files: Open your Faceswap
config.ini(or any custom configs) and check all path settings. If you entered a relative path likeUsers\YourName\datainstead of the full absolute pathC:\Users\YourName\data, Python might try to importUsersas a module instead of treating it as a filesystem path. - Reinstall Faceswap: A partial download or corrupted script could cause this. Try cloning the latest stable Faceswap repo fresh, or re-download the release zip, then re-install dependencies with the requirements file.
- Analyze the error traceback: Your screen recording screenshots should show a full error stack (lines starting with
File "somefile.py", line X, in <module>). Look for which script is trying toimport Users—this will pinpoint exactly where path parsing is broken. For example, if it’s in a custom script you wrote, you might have a typo in how you reference a file path.
Final Checks
Double-check that Python 3.8.5 is fully compatible with the latest Faceswap version. While 3.8 is generally supported, some newer features might require a slightly newer Python version (like 3.9+). If all else fails, try matching the exact Python version you used on your old working setup.
内容的提问来源于stack exchange,提问作者Blenderer

