Anaconda常用命令(conda)
Anaconda下载地址:
https://repo.anaconda.com/archive/
1.查询安装信息
conda info
2.看当前所有可用的环境kernel
conda env list
3.Anaconda创建虚拟环境
conda create -n myenv——name python=x.x
例:conda create -n mypytorch python=3.6
4.活虚拟环境
环境存储在envsAnaconda目录中的文件夹中。创建环境后,可以通过键入以下内容来激活它:
例:conda activate MyPyTorch
5.关闭虚拟环境
conda deactivate
6.删除虚拟环境
conda remove -n your_env_name --all
7.查询现在安装了哪些包
conda list
8.各种所需python包
pip install package_name 或者conda install package_name
9.将当前使用的环境中所包含的python包的名称进行打包
conda env export > 文件名.yaml
10.载入别人共享的环境
conda env update -f=/path/文件名.yml
11.Anaconda修改清华源,加速包下载:(win和linux都可用)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
设置搜索时显示通道地址
conda config --set show_channel_urls yes
- 请配置镜像源,下面是清华的镜像源
pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
常用镜像:
豆瓣 https://pypi.doubanio.com/simple/
网易 https://mirrors.163.com/pypi/simple/
阿里云 https://mirrors.aliyun.com/pypi/simple/
腾讯云 https://mirrors.cloud.tencent.com/pypi/simple
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
2.带源安装库
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 库名
pip3 install torch1.10.2+cu102 torchvision0.11.3+cu102 torchaudio===0.10.2+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html
3…一键生成和安装requirements.txt文件
在pycharm文件中选中下面的Terminal
输入pip freeze>requirements.txt
就能在该目录下生成requirements.txt
然后pip install -r requirements.txt即可安装库
4.Python安装包大全中:
https://www.lfd.uci.edu/~gohlke/pythonlibs/
5…py文件生成.exe文件
在终端输入
pyinstaller -F dpython.py