如何为Python 3.6.0安装包/模块?新手求助操作疑问
Hey there! Let's break down your problems step by step—since you're new to Python, these are super common hurdles, so don't worry 😊
scripts Folder The scripts folder is part of a standard Python installation; it holds essential tools like pip (the package installer you'll rely on constantly). If you don't have it, here's what's likely going on and how to fix it:
- You skipped adding Python to your system PATH during installation: On Windows, this is a easy-to-miss checkbox in the installer. On Mac/Linux, the installer usually handles this automatically, but custom installations sometimes skip this step.
- Your Python install is incomplete: Maybe you chose a minimal installation that excluded the
scriptsdirectory entirely.
Fixes:
- Reinstall Python (recommended for beginners): Grab the latest version from the official Python site, and make sure to check the box labeled "Add Python to PATH" (Windows) or follow prompts to include all standard components. This will create the
scriptsfolder automatically. - Manually add Python to your system PATH: If you don't want to reinstall, find your Python installation directory (e.g.,
C:\Python311on Windows,/usr/local/bin/python3on Mac/Linux). Add this directory (and thescriptssubfolder if it exists elsewhere) to your system's PATH environment variable. This lets your terminal locatepipand other Python tools.
requirements.txt Correctly Let's clear up the confusion around this file:
What is requirements.txt?
It's a plain text file where you list all the Python packages your project needs, often with specific version numbers (optional but recommended for consistency). For example:
requests==2.31.0 numpy==1.25.2 pandas==2.1.0
Where to put it?
Place it directly in the root folder of your Python project. If you're working on a project called my_first_project, save requirements.txt inside that folder—this keeps all your project files organized and easy to manage.
Where to run the command?
You'll need to use your terminal (Command Prompt/PowerShell on Windows, Terminal app on Mac/Linux) and first navigate to the folder where requirements.txt is stored. Here's how:
- Open your terminal application.
- Use the
cdcommand to switch to your project folder. For example:- Windows:
cd C:\Users\YourName\my_first_project - Mac/Linux:
cd ~/my_first_project
- Windows:
- Once you're in the correct folder, run the command:
pip3 install -r requirements.txt- If
pip3doesn't work, trypython -m pip install -r requirements.txtinstead—this ensures you're using the pip tied to your current Python installation, avoiding path-related errors.
- If
Quick Pre-Check:
Before running the install command, confirm Python and pip are working by typing these in your terminal:
python3 --version(orpython --versionon Windows)pip3 --version(orpip --version)
If these commands show a valid version number, you're ready to go!
内容的提问来源于stack exchange,提问作者Philip Svenningsen Arnevig

