Loading

环境配置、安装、命令、报错(anaconda&pip)

anaconda的基本命令

  • 安装虚拟环境
    conda create -n env_name python=xx
  • 删除虚拟环境
    conda remove -n env_name --all
  • conda install with conda-forge
    conda install --channel "conda-forge" package
    conda install -c conda-forge package
  • 换源
    阿里源
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/msys2
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/r

conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/Paddle
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/auto
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/biobakery
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/bioconda
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/c4aarch64
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/caffe2
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/deepmodeling
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/dglteam
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/fastai
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/fermi
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/idaholab
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/intel
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/matsci
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/menpo
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/mordred-descriptor
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/msys2
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/numba
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/ohmeta
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/omnia
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/plotly
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/psi4
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/pytorch
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/pytorch-test
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/pytorch3d
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/pyviz
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/qiime2
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/rapidsai
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/rdkit
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/simpleitk
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/stackless
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/ursky

conda config --set show_channel_urls yes

一些常用包的安装

  1. pytorch
    linux:
查看cuda版本
cat /usr/local/cuda/version.txt #这里查出来是10.2
上官网下载对应版本
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
或者pip安装
pip3 install torch torchvision torchaudio
  1. 安装paddle(指定版本)
pip install paddlepaddle==1.8.5 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

报错记录

  1. (mac m1)在虚拟环境中使用conda install scikit-learn安装成功之后,import sklearn的时候报错没有image
    解决方法:
  • 卸载conda uninstall sklearn
  • 使用conda-forge库重新安装 conda install -c conda-forge scikit-learn

一开始报错是numpy引用错误,解决办法也是卸了重安....
不知道是不是不同包的版本冲突...
conda install -c conda-forge numpy or pip install numpy

  1. (服务器)在服务器安装的时候报下面的错误
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) 
after connection broken
by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.
VerifiedHTTPSConnection object at 0x10b058850>, 
'Connection to pypi.python.org timed out. (connect timeout=15)')':

解决方法:换源

  • 一些国内常用的pypi源如下:
阿里云 http://mirrors.aliyun.com/pypi/simple/  【成功了】

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

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

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

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

解决办法

在你需要安装的xx后面添加-i + pypi源:
pip install xx -i http://pypi.douban.com/simple/
如果还出现下面的情况:
pypi.douban.com is not a trusted or secure host and is being ignored...
那么命令就变成这样:
pip install xx -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
也可以永久设置
参考:https://cloud.tencent.com/developer/article/1354614

添加jupyter kernel

1、在anaconda虚拟环境中安装conda install ipykernel
2、添加内核
python -m ipykernel install --name mmd2
如果报错:[Errno 13] Permission denied: '/usr/local/share/jupyter'

  • 执行:
    python -m ipykernel install --user --name mmd2

安装PYG包报错

  1. 错误记录
    在执行pip install pytorch_geometric之后,报错没有torch_scatter包,pip直接安装会显示c++错误,报错原因是pytorch版本与torch_scatter版本不匹配
  2. 解决办法

cuda版本查看指令nvcc -V

安装TF1-gpu

conda create -n sxb_tf1 python=3.7
conda activate sxb_tf1
conda install tensorflow-gpu==1.15.0
posted @ 2021-10-12 19:43  摇头晃脑学知识  阅读(223)  评论(0编辑  收藏  举报