内含保姆级截图+避坑指南,小白看完就能跑代码!
你是否想用Python轻松抓取全网数据,却卡在安装环节?别担心!本文用10张图解+真人实测,手把手教你从零搭建Python开发环境,30分钟解锁爬虫技能!文末还附赠「国内镜像加速秘籍」,下载速度直接翻倍!【本案例以一台win10系统64位云电脑为例】
Python安装:从此告别环境变量报错
下载与安装
官网直达:进入Python官网(python.org),点击「Downloads」→ 选择Windows/Mac对应版本(勾选3.8以上版本)。由于国内进入该网站会很慢,所以我们采用华为镜像源下载版本即可,其地址为:Index of python-local

下拉点击合适的版本,我们这里选择3.10.10版本,进入后根据自己的电脑系统选择python文件,最好选择.exe后缀名的下载,这样安装会简单一些。

关键操作:安装时务必勾选 Add Python to PATH(自动配置环境变量,避免后续报错)

建议选择CUstomiz installation选择,自定义安装路径。




出现这个界面就安装完成了!
验证是否成功
按下 Win+R 输入 cmd → 输入 python –version


若显示版本号(如 Python 3.10.10),恭喜安装成功!
IDE配置:选对工具效率翻倍
PyCharm社区版(推荐新手)
下载地址:JetBrains官网 → 选择「Community」免费版本,就是右侧的小字:Other versions


下载后按步骤安装即可。
选择安装路径:

最好全部勾选选,不用自己再另外配置。

点击下一步,然后点击安装,等待安装完成即可!


配置技巧:首次启动时选择「Dark主题」保护眼睛,设置中文界面(File→Settings→Plugins→搜索「Chinese」安装)
然后就可以新建项目了:

必备库安装:3行命令搞定爬虫工具链
一键安装核心库
项目建立时,记得选择我们安装的python为解释器,进入项目,打开终端(Terminal)输入:
pip install requests beautifulsoup4 lxml


作用说明:
- requests:抓取网页内容(如豆瓣电影页面)
- beautifulsoup4:解析HTML数据(提取标题、图片)
- lxml:加速解析效率(比默认解析器快3倍)
验证库是否生效
输入 python 进入交互模式 → 输入 import requests
若无报错,说明安装成功!

国内镜像加速:告别龟速下载!
临时加速(单次生效)
在安装命令后添加 -i 镜像地址:
pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple

永久配置(推荐)
新建文件:C:\Users\你的用户名\pip\pip.ini
写入内容:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com
从此下载速度提升10倍!

你的Python环境搭好了吗?欢迎在评论区晒出安装成功的截图!