Windows系统下如何将自制Python模块安装到本地环境?
Hey there! I totally get how disorienting it can be when a book uses Mac terminal commands but you're on Windows—let's break this down into simple, Windows-friendly steps that even a beginner can follow.
Step 1: Open Command Prompt or PowerShell
- Press
Win + Ron your keyboard, typecmd(orpowershell) and hit Enter. This opens your Windows command line tool.
Step 2: Navigate to Your Nester Folder
Your module is on the desktop in a folder called "Nester", so we need to tell the command line to go there:
- First, you’ll start in your user’s home directory by default when opening CMD. You can confirm this with
echo %USERPROFILE%. - Type
cd Desktopand hit Enter—this moves you to your desktop folder. - Then type
cd Nesterand hit Enter. Now you’re inside the folder with yoursetup.pyand module code.
Pro tip: If you’re unsure about the folder name, type
dirto see all files/folders in the current directory and double-check the spelling.
Step 3: Install the Module with pip
Now that you’re in the right folder, run one of these commands (try them in order if one doesn’t work):
- For most standard Windows Python setups:
pip install . - If you have multiple Python versions installed:
python -m pip install .(this ensures you’re using the pip linked to your active Python installation) - If you get a permission error:
pip install --user .(installs the module only for your user account, avoiding admin requirements)
Bonus: Development Mode (For Testing Changes)
If you plan to tweak your module code later and want those changes to take effect without reinstalling every time, use this command instead:pip install -e .
Quick Troubleshooting Checks
- Make sure your
setup.pyis actually in the Nester folder (rundirto confirm it’s listed). - If pip isn’t recognized as a command, you might need to add Python to your Windows PATH—just let me know if you hit this, and I’ll walk you through fixing it!
内容的提问来源于stack exchange,提问作者Icarus

