| Python 搭建环境与安装 pip 扩展
安装背景
系统 windows7 64位,安装的 python 版本为 3.6.7 ,此文档为过程总结。
Python 与 pip 下载与安装
下载
- 进入
https://www.python.org/
选择downloads
文章图片
Python 搭建环境与安装 pip 扩展_第1张图片" style="border:1px solid black; "> 官网首页 - 选择 3.6.7 版本
文章图片
Python 搭建环境与安装 pip 扩展_第2张图片" style="border:1px solid black; "> 选择3.6.7版本 - 拉到屏幕底部,选择
- Windows x86-64 executable installer
文章图片
Python 搭建环境与安装 pip 扩展_第3张图片" style="border:1px solid black; "> 选择64位安装包
- Windows x86-64 executable installer
- 直接对下载好的安装包双进运行
- 选择自定义安装
- 勾选 add python3.6 to path(自动添加环境变量)
- 下一步
- 勾选
- document
- pip(必须选)
- .. 其他的多装总比少装强
- 安装路径,c:\python\Python3.6(可自行定义)
- 下一步
- 安装完成
- 开始,运行,进入cmd命令行
- 敲命令 python
- windodws 用 ctrl+z 退出交互界面
- 敲命令 pip
- 命令存在
- 如果提示命令不存在
- 很可能是你的 环境变量未设置好
安装 pipenv 它是一个项目虚拟环境管理工具。
利用 pip 安装
pip install pipenv
执行该命令自动进入下载安装过程。
创建项目
- 在电脑中创建文件夹,比如 I:\Python\test
- 在命令行切换到此
- cmd: cd I:\Python\test
- 执行 pipenv 的初始化命令
- pipenv --python 3.6
文章图片
Python 搭建环境与安装 pip 扩展_第4张图片" style="border:1px solid black; "> 执行 pipenv 初始化命令之后的画面
- pipenv --python 3.6
- 进入 pipenv 的虚拟环境
- pipenv shell
文章图片
进入 pipenv 的虚拟环境
- pipenv shell
- 安装一个库试试
- pip install requests
文章图片
Python 搭建环境与安装 pip 扩展_第5张图片" style="border:1px solid black; "> 安装 requests 库界面
- pip install requests
- 虚拟化环境存放路径
- 默认 c:\users\administrator.vi*****
文章图片
Python 搭建环境与安装 pip 扩展_第6张图片" style="border:1px solid black; "> 本次安装虚拟化环境存放路径
- 默认 c:\users\administrator.vi*****
- 【| Python 搭建环境与安装 pip 扩展】OK End
地址 http://www.jetbrains.com/pycharm/download/

文章图片
Python 搭建环境与安装 pip 扩展_第7张图片" style="border:1px solid black; "> 下载 Pro 版本
创建项目 直接选择我们刚刚的项目路径
I:\Python\test
让项目使用pipenv的虚拟环境
file -> setting -> project:test

文章图片
Python 搭建环境与安装 pip 扩展_第8张图片" style="border:1px solid black; "> 如图所示 进一步选择
interperter
在下拉选单中选中我们刚刚的虚拟化环境目录即可。
文章图片
Python 搭建环境与安装 pip 扩展_第9张图片" style="border:1px solid black; "> 选择上文中创建的虚拟环境目录
interperter 中没有怎么办? 下拉选单中,选择
show all

文章图片
Python 搭建环境与安装 pip 扩展_第10张图片" style="border:1px solid black; "> 第一步: interperter 中没有的话,点击下拉选单之后选择 show all

文章图片
Python 搭建环境与安装 pip 扩展_第11张图片" style="border:1px solid black; "> 第二步:点击加号+

文章图片
Python 搭建环境与安装 pip 扩展_第12张图片" style="border:1px solid black; "> 第三步:选择已经存在的,不要选择新建的
然后在 existing environment,在右侧
...
选中虚拟环境的 python.exe 即可。
文章图片
Python 搭建环境与安装 pip 扩展_第13张图片" style="border:1px solid black; "> 第四步:选择已存在的之后点击最右边的 …

文章图片
Python 搭建环境与安装 pip 扩展_第14张图片" style="border:1px solid black; "> 第五步:选择 python.exe 既可
一般情况下,默认路径:
c:\users\administrator\.virtualenvs\项目名\Scripts\python.exe

文章图片
Python 搭建环境与安装 pip 扩展_第15张图片" style="border:1px solid black; "> 切记切记!!! 然后一直点 ok 即可
效果如下

文章图片
Python 搭建环境与安装 pip 扩展_第16张图片" style="border:1px solid black; "> 可以看到会出现两个虚拟环境的选项
最终可以看到编辑器中包含了刚刚创建的虚拟环境

文章图片
Python 搭建环境与安装 pip 扩展_第17张图片" style="border:1px solid black; "> 看到这里证明编辑器配置成功了 总结 至此,整个项目环境配置完毕。
推荐阅读
- 人生感悟记#环境仪器宋庆国成长记#072
- python学习之|python学习之 实现QQ自动发送消息
- 逻辑回归的理解与python示例
- 六步搭建ES6语法环境
- python自定义封装带颜色的logging模块
- 【Leetcode/Python】001-Two|【Leetcode/Python】001-Two Sum
- Python基础|Python基础 - 练习1
- Python爬虫|Python爬虫 --- 1.4 正则表达式(re库)
- Python(pathlib模块)
- python青少年编程比赛_第十一届蓝桥杯大赛青少年创意编程组比赛细则