使用 Python

时间:2023-03-09 23:04:06
使用 Python

使用 Python

Python 官网及镜像

官网https://www.python.org/

镜像http://npm.taobao.org/mirrors/python/

安装玩Python,将安装目录加入Windows搜索路径。

配置镜像

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣:http://pypi.douban.com/simple/

安装包

临时方式

在CMD中输入(Python 安装目录要加入路径!):

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas

从清华大学的镜像安装pandas包,同时也安装相依的包。

永久方式

Windows下,在系统当前用户目录(%USERPROFILE%)中新建一个pip目录:%USERPROFILE%\pip,新建文件pip.ini,内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = mirrors.aliyun.com

然后使用pip install -i pandas安装pandas包。

更新包

pip帮助:pip help

查看安装的包:pip list -o

如更新pandas: pip install --upgrade pandas

更新pip: python -m pip install --upgrade pip

更新所有已经安装的包:

import pip
from pip._internal.utils.misc import get_installed_distributions
from subprocess import call for dist in get_installed_distributions():
    call("pip install --upgrade " + dist.project_name, shell=True)

Jupyter Notebook

安装jupyter notebook(需要浏览器):pip install jypter

安装jupyter qtconsole(单独窗口): pip install pyqt5