pip无法识别"-r"命令:Flask环境搭建安装命令报错求助
Hey there! I see you're new to Flask and ran into a tricky little error when setting up your environment—let's sort this out quickly.
The core issue here is the dash you used in –r: that’s a long em dash (the kind you might accidentally get from copying text or certain keyboard layouts), but pip only recognizes the standard short hyphen (-) for its -r flag. That’s why it’s throwing the "Invalid requirement: '–r'" error—it’s treating –r like a package name instead of a command-line option.
Here’s how to fix this step by step:
- Re-type the command manually: Skip copying/pasting and type
pip install -r requirements.txtdirectly. Make sure the-beforeris the regular hyphen (the same key you use for minus signs on your keyboard). - Verify your working directory: Ensure you’re in the same folder where your
requirements.txtfile lives when you run the command. If not, navigate to that folder withcd /path/to/your/projector use the full file path likepip install -r /path/to/your/project/requirements.txt. - Double-check your virtual environment is active: Look at the start of your terminal prompt—you should see your virtual environment’s name (like
(venv)). If it’s not active, re-activate it before running the pip command.
Follow these steps, and that error should vanish—pip will correctly read your requirements file and install all the packages you need for your Flask app.
内容的提问来源于stack exchange,提问作者Rebecca Andrews

