跳至主要內容

Windows使用Python

知识库编程技巧Pythonpython大约 1 分钟

python 安装

# 升级pip版本
python -m pip install --upgrade pip

jupyter 安装

# 安装
pip install jupyter
# 修改默认目录 生成默认配置文件(可选)
jupyter notebook --generate-config
# 修改配置文件属性 c.NotebookApp.notebook_dir = 'E:\\00000000\\jupyter'
# 运行 访问http://localhost:8088/tree
jupyter notebook

centos 安装 python

wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz
tar -xvf Python-3.11.1.tgz
cd Python-3.11.1
./configure --prefix=/usr/local/python
make & make install
## 创建软链接
ln -s /usr/local/python/bin/3.11.1/usr/bin/python

Anacond

配置

## 查看版本
conda --version
conda info
## 添加国内源
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
## 设置搜索时显示通道地址
conda config --set show_channel_urls yes
## 删除默认源
# conda config --remove channels defaults
## 查看通道地址
conda config --show channels

使用

## 查看所有的环境
conda env list

## 新建环境
## conda create -n noti jupyter notebook
conda create --name python38 python=3.8
# 安装好后,使用activate激活某个环境
# for Windows
activate python38 
# for Linux & Mac
source activate python38
python --version

## 退出环境
# for Windows
deactivate python38 
# for Linux & Mac
source deactivate python38 

## 卸载环境
conda remove --name python38 --all

迁移

## 要查看当前环境中所有安装了的包可以用
conda list
## 如果想要导出当前环境的包信息可以用,将包信息存入yaml文件中.
conda env export > environment.yaml
## 当需要重新创建一个相同的虚拟环境时可以用
conda env create -f environment.yaml