Windows 10及PyCharm中无法安装配置Python Requests模块求助
Fixing Requests Module Installation Failures on Windows 10 (and PyCharm Configuration Errors)
Hey there, let's work through this Requests module installation problem together—it’s a super common snag, so we’ll get it fixed in no time!
First: Troubleshoot Your System-Wide Python Environment
Before diving into PyCharm, let's make sure your base Python setup is solid:
- Verify Python is in your PATH: Open Command Prompt (Win+R, type
cmdand hit enter). Runpython --versionorpy --version—if you get an error like "not recognized as an internal or external command", you need to re-install Python and make sure to check the "Add Python to PATH" box during setup. - Install Requests via pip (with proper permissions): In Command Prompt, run
pip install requests. If you hit a permission error, right-click Command Prompt and select "Run as administrator", then re-run the command. - Fix network/download issues with a domestic mirror: If pip is slow or fails to download the package, use a faster mirror:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests - Resolve Python version conflicts: If you have both Python 2 and 3 installed, explicitly use
pip3 install requeststo target Python 3 (since Requests is mostly used with Python 3 now).
Next: Fix PyCharm Installation/Configuration Errors
If the system-wide install works but PyCharm is still throwing errors, the issue is almost always related to PyCharm's selected interpreter:
- Confirm PyCharm is using the correct Python interpreter:
- Open your project in PyCharm, go to
File > Settings > Project: [Your Project Name] > Python Interpreter. - Check the interpreter listed at the top—does it match the version you used in Command Prompt? If not, click the gear icon >
Add, then navigate to your Python executable (usually inC:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX\python.exe).
- Open your project in PyCharm, go to
- Install Requests directly in PyCharm:
- In the Python Interpreter page, click the
+button in the top-right. - Search for
requests, select it, then clickInstall Package.
- In the Python Interpreter page, click the
- Add a mirror to PyCharm if downloads fail:
- In the Python Interpreter settings, click the gear icon >
Manage Repositories. - Add
https://pypi.tuna.tsinghua.edu.cn/simple(or another trusted mirror), then try installing Requests again.
- In the Python Interpreter settings, click the gear icon >
- Check virtual environment issues: If you're using a virtual environment for your project, PyCharm might be using that instead of your system Python. Make sure to install Requests inside the virtual environment—either via the Python Interpreter settings (select the venv's
python.exe) or activate the venv in Command Prompt and runpip install requests.
Last Resort: Manual Installation
If all else fails, try manually installing the Requests wheel file:
- Download the correct
.whlfile for your Python version and Windows system (look for a file likerequests-2.31.0-py3-none-any.whl—the "py3" means it works for all Python 3 versions). - Open Command Prompt, navigate to the folder where you downloaded the file, then run:
pip install requests-2.31.0-py3-none-any.whl - Also, temporarily disable your firewall or antivirus software—sometimes they block pip's network requests.
内容的提问来源于stack exchange,提问作者venkat
相关产品推荐
相关产品推荐

