blog/source/_posts/Python/Python环境搭建.md
2022-09-03 18:06:05 +08:00

62 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Python 环境搭建
categories:
- Python
keywords:
- Python
- pip
- pypi
- pipenv
tags:
- Python
date: 2022-09-03 12:13:10
---
# 安装 Python
只有 Windows 用户需要注意一点,用安装程序安装时一定要记得勾选 `Add Python to PATH`
# pip
Python 包管理器 pip 的配置文件在 `$HOME/.config/pip/pip.conf`
执行以下语句,可以为当前用户设置 pypi 安装源:
``` sh
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
```
执行完毕后,`pip.conf` 中会添加如下设置:
``` conf pip.conf
[global]
index-url = https://mirrors.ustc.edu.cn/pypi/web/simple
```
pip 常用的命令:
``` sh
pip install <package> --user # 为当前用户安装指定的包
pip list --user # 列出为当前用户安装的包
pip show <package> # 显示指定包的详情
pip install <package> --upgrade # 升级指定的包,或可用短参数-U
```
当前用户安装的包保存在 `$HOME/.local/lib/python3.xx/site-packages` 中。
# pipenv
一个 Python 虚拟环境管理器,安装方法 `pip install pipenv --user` 。
添加将以下环境参数pipenv 就可以在当前路径中创建 Python 虚拟环境了:
``` conf env
PIPENV_VENV_IN_PROJECT=enabled
PIPENV_IGNORE_VIRTUALENVS=1
PIPENV_VERBOSITY=-1
```
# vscode
在 VS Code 中的配置 Python 开发环境,待续...