python 工具介绍 —— Anaconda(水蟒)
以前,在linux下面可以使用Pyenv,那windows下面就靠这个工具了。
# 下载安装
网络不好的可以去这里直接拿安装包
安装完毕后,添加环境变量,下面是我的按照目录
以这个安装目录为例:D:\Conda_\anaconda3\
# 添加环境变量
G:\Conda_\anaconda3\Scripts G:\Conda_\anaconda3 G:\Conda_\anaconda3\Library\bin G:\Conda_\anaconda3\Library\mingw-w64 G:\Conda_\anaconda3\Library\usr\bin
打开一个CMD,查看conda --version
# conda更新
conda update conda
conda update anaconda
# conda更新python版本
conda install python=3.x.x
# conda --help
C:\Users\loki>conda --help usage: conda-script.py [-h] [-V] command ... conda is a tool for managing and deploying applications, environments and packages. Options: positional arguments: command clean Remove unused packages and caches. compare Compare packages between conda environments. config Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file (C:\Users\loki\.condarc) by default. create Create a new conda environment from a list of specified packages. help Displays a list of available conda commands and their help strings. info Display information about current conda install. init Initialize conda for shell interaction. [Experimental] install Installs a list of packages into a specified conda environment. list List linked packages in a conda environment. package Low-level conda package utility. (EXPERIMENTAL) remove Remove a list of packages from a specified conda environment. uninstall Alias for conda remove. run Run an executable in a conda environment. [Experimental] search Search for packages and display associated information. The input is a MatchSpec, a query language for conda packages. See examples below. update Updates conda packages to the latest compatible version. upgrade Alias for conda update. optional arguments: -h, --help Show this help message and exit. -V, --version Show the conda version number and exit. conda commands available from other packages: build content-trust convert debug develop env index inspect metapackage render repo server skeleton token verify C:\Users\loki>conda --help |more usage: conda-script.py [-h] [-V] command ... conda is a tool for managing and deploying applications, environments and packages. Options: positional arguments: command clean Remove unused packages and caches. compare Compare packages between conda environments. config Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file (C:\Users\loki\.condarc) by default. create Create a new conda environment from a list of specified packages. help Displays a list of available conda commands and their help strings. info Display information about current conda install. init Initialize conda for shell interaction. [Experimental] install Installs a list of packages into a specified conda environment. list List linked packages in a conda environment. package Low-level conda package utility. (EXPERIMENTAL) remove Remove a list of packages from a specified conda environment. uninstall Alias for conda remove. run Run an executable in a conda environment. [Experimental] search Search for packages and display associated information. The input is a MatchSpec, a query language for conda packages. See examples below. update Updates conda packages to the latest compatible version. upgrade Alias for conda update. optional arguments: -h, --help Show this help message and exit. -V, --version Show the conda version number and exit. conda commands available from other packages: build content-trust convert debug develop env index inspect metapackage render repo server skeleton token verify
# 创建一个新环境
conda create -n py34 python=3.4
Note: 遇到一个报错
解决方法:
找到 .condarc 文件路径,我的是在C:\Users\loki,修改内容为: (清华大学镜像) 阿里云镜像
channels: - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ ssl_verify: true show_channel_urls: true
Note: 遇到一个报错20230411
PackagesNotFoundError: The following packages are not available from current channels
解决方法:
conda config --set ssl_verify false # 关闭https验证
最后使用的源: .condarc 文件内容如下
channels: - defaults - conda-forge show_channel_urls: true default_channels: - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels: conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud ssl_verify: false
# 按照完毕后,查看是否已经安装成功, conda env list
# 切换环境版本 activate <刚刚取的名字>
# 如果记不清了可以conda env list 命令来查询
# 卸载环境 conda remove --name py34 --all
# 安装/卸载/更新第三方包
conda install requests Or pip install requests
conda remove requests Or pip uninstall requests
# 查看环境包信息
conda list
# 导入导出环境
conda env export -n base > d:\environment.yaml ## 导出名叫 base的环境
conda env create -f environment.yaml ## 导入
与JetBrains PyCharm 连接
在Setting => Project => Project Interpreter 里面修改 Project Interpreter , 点击齿轮标志再点击Add Local为你某个环境的python.exe解释器就行了
# 2024-03-18 WSL-Ubtun
## 出现0x800701bc这个错误
补丁需要安装,wsl --update
# windows文件共享
\\wsl$
# 查看当前子系统
wsl -l -v
# 关闭当前子系统
wsl --shutdown
# 注销某一个特定的子系统
wsl --unregister <系统名>
Docker-Desktop 储存路径更改
说明:默认 Docker-desktop 初始化的两个 WSL 子系统会保存在 C盘 下,避免占用 C盘 空间,需要进行储存路径更改。
docker-desktop:保存的是程序
docker-desktop-data: 保存的镜像
在关闭docker-desktop的情况下再进行操作。
# 通过wsl命令将这两个子系统进行迁移
备份命令
wsl --export docker-desktop docker-desktop.tar
wsl --export docker-desktop-data docker-desktop-data.tar
删除命令
wsl --unregister docker-desktop
wsl --unregister docker-desktop-data
导入命令
wsl --import docker-desktop X:\docker\docker-desktop docker-desktop.tar
wsl --import docker-desktop-data X:\docker\docker-desktop-data docker-desktop-data.tar
注意: 两个子系统文件使用的目录限制不能为同一个目录, 完成以上操作启动docker-desktop下载镜像文件就不会保存到C盘啦。
参考资料:https://blog.csdn.net/weixin_41166785/article/details/130989061
安装Linux Conda
下载一个sh文件,直接在系统上运行
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 安装环境变量
vim ~/.bashrc
export PATH=~/miniconda3/bin:$PATH # 注意看自己home目录或者conda的名字
source ~/.bashrc
# linux 下面切换版本使用的命令
conda activate <版本名>
# 查看已经安装版本命令
conda info -e
conda env list
参考资料:
https://blog.csdn.net/ITLearnHall/article/details/81708148/